protected function getSlice(): Closure
    {
        return function ($stack, $stage) {
            return function ($traveler) use ($stack, $stage) {
                // If the $stage is an instance of a Closure, we will just call it directly.
                if ($stage instanceof Closure) {
                    return $stage($traveler, $stack);
                }

                // Otherwise we'll resolve the stages out of the container and call it with
                // the appropriate method and arguments, returning the results back out.
                if ($this->container && ! \is_object($stage) && \is_string($stage)) {
                    return $this->sliceThroughContainer($traveler, $stack, $stage);
                }

                if (\is_array($stage)) {
                    $parameters = [$traveler, $stack];
                    $class      = \array_shift($stage);

                    if (\is_object($class) && (\is_string($class) && \class_exists($class))) {
                        throw new \InvalidArgumentException(\sprintf(
                            'The first entry in the array must be a class, [%s] given.',
                            \is_object($class) ? \get_class($class) : \gettype($class)
                        ));
                    }

                    /** @var \Closure $object */
                    $object = (new ReflectionClass($class))->newInstanceArgs($stage);

                    return $object(...$parameters);
                }

                // If the pipe is already an object we'll just make a callable and pass it to
                // the pipe as-is. There is no need to do any extra parsing and formatting
                // since the object we're given was already a fully instantiated object.
                $parameters = [$traveler, $stack];

                return $stage->{$this->method}(...$parameters);
            };
        };
    }
protected function getSlice(): Closure
    {
        return function ($stack, $stage) {
            return function ($traveler) use ($stack, $stage) {
                // If the $stage is an instance of a Closure, we will just call it directly.
                if ($stage instanceof Closure) {
                    return $stage($traveler, $stack);
                }

                // Otherwise we'll resolve the stages out of the container and call it with
                // the appropriate method and arguments, returning the results back out.
                if ($this->container && ! \is_object($stage) && \is_string($stage)) {
                    return $this->sliceThroughContainer($traveler, $stack, $stage);
                }

                if (\is_array($stage)) {
                    $parameters = [$traveler, $stack];
                    $class      = \array_shift($stage);

                    if (\is_object($class) && (\is_string($class) && \class_exists($class))) {
                        throw new \InvalidArgumentException(\sprintf(
                            'The first entry in the array must be a class, [%s] given.',
                            \is_object($class) ? \get_class($class) : \gettype($class)
                        ));
                    }

                    /** @var \Closure $object */
                    $object = (new ReflectionClass($class))->newInstanceArgs($stage);

                    return $object(...$parameters);
                }

                // If the pipe is already an object we'll just make a callable and pass it to
                // the pipe as-is. There is no need to do any extra parsing and formatting
                // since the object we're given was already a fully instantiated object.
                $parameters = [$traveler, $stack];

                return $stage->{$this->method}(...$parameters);
            };
        };
    }
protected function getSlice ( ) : Closure { return function ( $ stack , $ stage ) { return function ( $ traveler ) use ( $ stack , $ stage ) { // If the $stage is an instance of a Closure, we will just call it directly. if ( $ stage instanceof Closure ) { return $ stage ( $ traveler , $ stack ) ; } // Otherwise we'll resolve the stages out of the container and call it with // the appropriate method and arguments, returning the results back out. if ( $ this -> container && ! \ is_object ( $ stage ) && \ is_string ( $ stage ) ) { return $ this -> sliceThroughContainer ( $ traveler , $ stack , $ stage ) ; } if ( \ is_array ( $ stage ) ) { $ parameters = [ $ traveler , $ stack ] ; $ class = \ array_shift ( $ stage ) ; if ( \ is_object ( $ class ) && ( \ is_string ( $ class ) && \ class_exists ( $ class ) ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The first entry in the array must be a class, [%s] given.' , \ is_object ( $ class ) ? \ get_class ( $ class ) : \ gettype ( $ class ) ) ) ; } /** @var \Closure $object */ $ object = ( new ReflectionClass ( $ class ) ) -> newInstanceArgs ( $ stage ) ; return $ object ( ... $ parameters ) ; } // If the pipe is already an object we'll just make a callable and pass it to // the pipe as-is. There is no need to do any extra parsing and formatting // since the object we're given was already a fully instantiated object. $ parameters = [ $ traveler , $ stack ] ; return $ stage -> { $ this -> method } ( ... $ parameters ) ; } ; } ; }
Get a Closure that represents a slice of the application onion.

@return \Closure
Get a Closure that represents a slice of the application onion .