protected static function factory($factory)
    {
        if (is_callable($factory)) {
            return $factory();
        }

        $type = gettype($factory);
        if ($type == 'string' && count(EventManager::instance()->listeners($factory)) > 0) {
            return EventManager::instance()->dispatch($factory)->result;
        }

        throw new \InvalidArgumentException('No suitable factory found');
    }
protected static function factory($factory)
    {
        if (is_callable($factory)) {
            return $factory();
        }

        $type = gettype($factory);
        if ($type == 'string' && count(EventManager::instance()->listeners($factory)) > 0) {
            return EventManager::instance()->dispatch($factory)->result;
        }

        throw new \InvalidArgumentException('No suitable factory found');
    }
protected static function factory ( $ factory ) { if ( is_callable ( $ factory ) ) { return $ factory ( ) ; } $ type = gettype ( $ factory ) ; if ( $ type == 'string' && count ( EventManager :: instance ( ) -> listeners ( $ factory ) ) > 0 ) { return EventManager :: instance ( ) -> dispatch ( $ factory ) -> result ; } throw new \ InvalidArgumentException ( 'No suitable factory found' ) ; }
Adapter factory.

@param callable|string|array $factory The factory to use and build the adapter.

@throws \InvalidArgumentException Thrown when no suitable factory is found.

@return mixed
Adapter factory .