private function createInstanceFromFactory($factory)
    {   
        if ($factory instanceof ServiceFactoryInterface)
        {
            return $factory->create($this);
        }
        elseif ($factory instanceof Closure)
        {
            return $factory($this);
        }

        // otherwise throw an exception 
        throw new InvalidServiceException('Service could not be resolved, the registered factory is invalid.');
    }
private function createInstanceFromFactory($factory)
    {   
        if ($factory instanceof ServiceFactoryInterface)
        {
            return $factory->create($this);
        }
        elseif ($factory instanceof Closure)
        {
            return $factory($this);
        }

        // otherwise throw an exception 
        throw new InvalidServiceException('Service could not be resolved, the registered factory is invalid.');
    }
private function createInstanceFromFactory ( $ factory ) { if ( $ factory instanceof ServiceFactoryInterface ) { return $ factory -> create ( $ this ) ; } elseif ( $ factory instanceof Closure ) { return $ factory ( $ this ) ; } // otherwise throw an exception  throw new InvalidServiceException ( 'Service could not be resolved, the registered factory is invalid.' ) ; }
Resolve a service instance from the given factory object.

@param ServiceFactoryInterface|Closure           $factory The factory object.

@return mixed The instance of created by the factory object.
Resolve a service instance from the given factory object .