src/Library/ServiceContainer/ServiceContainer.php
protected function _constructService($name, array $arguments = array())
    {
        if ($this->hasProvider($name)) {
            $data = $this->getProvider($name);
            if (is_object($data) && CodeHelper::implementsInterface($data, 'Library\ServiceContainer\ServiceProviderInterface')) {
                $data->boot($this);
                $this->setService($name, $data);
            } elseif (is_callable($data) || ($data instanceof \Closure)) {
                try {
                    $item = call_user_func_array(
                        $data, array($this, $name, $arguments)
                    );
                    $this->setService($name, $item);
                } catch (\Exception $e) {
                    throw new ErrorException(
                        sprintf('An error occurred while trying to create a "%s" service!', $name),
                        0, 1, __FILE__, __LINE__, $e
                    );
                }
            } elseif (is_array($data)) {
                $this->setService(
                    $name,
                    $data[1],
                    isset($data[2]) ? $data[2] : false
                );
            } else {
                throw new ErrorException(
                    sprintf('A "%s" service constructor must be a valid callback!', $name)
                );
            }
        }
    }
protected function _constructService($name, array $arguments = array())
    {
        if ($this->hasProvider($name)) {
            $data = $this->getProvider($name);
            if (is_object($data) && CodeHelper::implementsInterface($data, 'Library\ServiceContainer\ServiceProviderInterface')) {
                $data->boot($this);
                $this->setService($name, $data);
            } elseif (is_callable($data) || ($data instanceof \Closure)) {
                try {
                    $item = call_user_func_array(
                        $data, array($this, $name, $arguments)
                    );
                    $this->setService($name, $item);
                } catch (\Exception $e) {
                    throw new ErrorException(
                        sprintf('An error occurred while trying to create a "%s" service!', $name),
                        0, 1, __FILE__, __LINE__, $e
                    );
                }
            } elseif (is_array($data)) {
                $this->setService(
                    $name,
                    $data[1],
                    isset($data[2]) ? $data[2] : false
                );
            } else {
                throw new ErrorException(
                    sprintf('A "%s" service constructor must be a valid callback!', $name)
                );
            }
        }
    }
protected function _constructService ( $ name , array $ arguments = array ( ) ) { if ( $ this -> hasProvider ( $ name ) ) { $ data = $ this -> getProvider ( $ name ) ; if ( is_object ( $ data ) && CodeHelper :: implementsInterface ( $ data , 'Library\ServiceContainer\ServiceProviderInterface' ) ) { $ data -> boot ( $ this ) ; $ this -> setService ( $ name , $ data ) ; } elseif ( is_callable ( $ data ) || ( $ data instanceof \ Closure ) ) { try { $ item = call_user_func_array ( $ data , array ( $ this , $ name , $ arguments ) ) ; $ this -> setService ( $ name , $ item ) ; } catch ( \ Exception $ e ) { throw new ErrorException ( sprintf ( 'An error occurred while trying to create a "%s" service!' , $ name ) , 0 , 1 , __FILE__ , __LINE__ , $ e ) ; } } elseif ( is_array ( $ data ) ) { $ this -> setService ( $ name , $ data [ 1 ] , isset ( $ data [ 2 ] ) ? $ data [ 2 ] : false ) ; } else { throw new ErrorException ( sprintf ( 'A "%s" service constructor must be a valid callback!' , $ name ) ) ; } } }
Construct a service based on its `constructor` item and references it

@param   string  $name
@param   array   $arguments
@return  void
@throws  ErrorException
Construct a service based on its constructor item and references it