public function singleton(string $name, callable $callback = null)
    {
        static $instance = [];

        // if closure callback given we will create a singleton instance of class
        // and return it to user
        if ($callback instanceof Closure) {
            if (!isset($instance[$name])) {
                $instance[$name] = $callback($this);
            }

            return $this->stack[$name] = $instance[$name];
        }

        /*
         | If callback is not instance of closure then we will simply
         | create a singleton instance and return it
         */
        if (!isset($instance[$name])) {
            $instance[$name] = new $name();
        }

        return $instance[$name];
    }