src/Container.php
public function get(string $serviceName)
    {
        // if the service container itself is requested
        if ($serviceName === 'container') { 
            return $this;
        }

        // check if the service name has a registered service type
        if (!isset($this->serviceResolverType[$serviceName]))
        {
            throw new UnknownServiceException('Could not find service named "' . $serviceName . '" registered in the container.');
        }
        $serviceResolverType = $this->serviceResolverType[$serviceName];

        // check if a service instance already exists
        if (
            isset($this->resolvedSharedServices[$serviceName]) && 
            $serviceResolverType !== static::RESOLVE_FACTORY
        ) {
            return $this->resolvedSharedServices[$serviceName];
        }

        switch ($serviceResolverType)
        {
            // Default resolver for all services that are defined 
            // directly in the container. We can skip here an unnecessary method call.
            case static::RESOLVE_METHOD:
                return $this->{$this->resolverMethods[$serviceName]}();
            break;

            case static::RESOLVE_PROVIDER:
                return $this->resolveServiceProvider($serviceName);
            break;

            case static::RESOLVE_FACTORY:
                return $this->resolveServiceFactory($serviceName);
            break;

            case static::RESOLVE_SHARED:
                return $this->resolveServiceShared($serviceName);
            break;

            default:
                throw new UnknownServiceException('Could not resolve service named "' . $serviceName . '", the resolver type is unkown.');
            break;
        }
    }
public function get(string $serviceName)
    {
        // if the service container itself is requested
        if ($serviceName === 'container') { 
            return $this;
        }

        // check if the service name has a registered service type
        if (!isset($this->serviceResolverType[$serviceName]))
        {
            throw new UnknownServiceException('Could not find service named "' . $serviceName . '" registered in the container.');
        }
        $serviceResolverType = $this->serviceResolverType[$serviceName];

        // check if a service instance already exists
        if (
            isset($this->resolvedSharedServices[$serviceName]) && 
            $serviceResolverType !== static::RESOLVE_FACTORY
        ) {
            return $this->resolvedSharedServices[$serviceName];
        }

        switch ($serviceResolverType)
        {
            // Default resolver for all services that are defined 
            // directly in the container. We can skip here an unnecessary method call.
            case static::RESOLVE_METHOD:
                return $this->{$this->resolverMethods[$serviceName]}();
            break;

            case static::RESOLVE_PROVIDER:
                return $this->resolveServiceProvider($serviceName);
            break;

            case static::RESOLVE_FACTORY:
                return $this->resolveServiceFactory($serviceName);
            break;

            case static::RESOLVE_SHARED:
                return $this->resolveServiceShared($serviceName);
            break;

            default:
                throw new UnknownServiceException('Could not resolve service named "' . $serviceName . '", the resolver type is unkown.');
            break;
        }
    }
Retrieve a service from the container.

@throws UnknownServiceException When a service could not be found or is unresolvable.

@param string            $serviceName The name / Identifier of the service to look for.

@return mixed The requested service.