src/Pipeline/Containerized.php
protected function build($stage)
	{
		if ($stage instanceof MiddlewareInterface) {
			return $stage;
		}

		if ($this->container->has($stage)) {
			$stage = $this->container->get($stage);
			if ($stage instanceof RequestHandlerInterface) {
				return new RequestHandler($stage);
			}

			if ($stage instanceof MiddlewareInterface) {
				return $stage;
			}

			throw new \RuntimeException("Stage is not a valid " . MiddlewareInterface::class);
		}

		// Support aura/di
		if (method_exists($this->container, 'newInstance')) {
			return $this->container->newInstance($stage);
		}

		throw new \RuntimeException("Unable to resolve $stage");
	}
protected function build($stage)
	{
		if ($stage instanceof MiddlewareInterface) {
			return $stage;
		}

		if ($this->container->has($stage)) {
			$stage = $this->container->get($stage);
			if ($stage instanceof RequestHandlerInterface) {
				return new RequestHandler($stage);
			}

			if ($stage instanceof MiddlewareInterface) {
				return $stage;
			}

			throw new \RuntimeException("Stage is not a valid " . MiddlewareInterface::class);
		}

		// Support aura/di
		if (method_exists($this->container, 'newInstance')) {
			return $this->container->newInstance($stage);
		}

		throw new \RuntimeException("Unable to resolve $stage");
	}
protected function build ( $ stage ) { if ( $ stage instanceof MiddlewareInterface ) { return $ stage ; } if ( $ this -> container -> has ( $ stage ) ) { $ stage = $ this -> container -> get ( $ stage ) ; if ( $ stage instanceof RequestHandlerInterface ) { return new RequestHandler ( $ stage ) ; } if ( $ stage instanceof MiddlewareInterface ) { return $ stage ; } throw new \ RuntimeException ( "Stage is not a valid " . MiddlewareInterface :: class ) ; } // Support aura/di if ( method_exists ( $ this -> container , 'newInstance' ) ) { return $ this -> container -> newInstance ( $ stage ) ; } throw new \ RuntimeException ( "Unable to resolve $stage" ) ; }
Builds the stage as a

@param $stage
@return MiddlewareInterface
@throws \Psr\Container\ContainerExceptionInterface
@throws \Psr\Container\NotFoundExceptionInterface
Builds the stage as a