public static function create($type, array $params = [])
    {
        if (is_string($type)) {
            return static::$di->getOrCreate($type, $params);
        } elseif (is_array($type) && isset($type['class'])) {
            $class = $type['class'];
            unset($type['class']);
            return static::$di->getOrCreate($class, $params, $type);
        } elseif (is_callable($type, true)) {
            return static::$di->invoke($type, $params);
        } elseif (is_array($type)) {
            throw new \Reaction\DI\Exceptions\InvalidConfigException('Object configuration must be an array containing a "class" element.');
        }

        throw new \Reaction\DI\Exceptions\InvalidConfigException('Unsupported configuration type: ' . gettype($type));
    }
public static function create($type, array $params = [])
    {
        if (is_string($type)) {
            return static::$di->getOrCreate($type, $params);
        } elseif (is_array($type) && isset($type['class'])) {
            $class = $type['class'];
            unset($type['class']);
            return static::$di->getOrCreate($class, $params, $type);
        } elseif (is_callable($type, true)) {
            return static::$di->invoke($type, $params);
        } elseif (is_array($type)) {
            throw new \Reaction\DI\Exceptions\InvalidConfigException('Object configuration must be an array containing a "class" element.');
        }

        throw new \Reaction\DI\Exceptions\InvalidConfigException('Unsupported configuration type: ' . gettype($type));
    }
public static function create ( $ type , array $ params = [ ] ) { if ( is_string ( $ type ) ) { return static :: $ di -> getOrCreate ( $ type , $ params ) ; } elseif ( is_array ( $ type ) && isset ( $ type [ 'class' ] ) ) { $ class = $ type [ 'class' ] ; unset ( $ type [ 'class' ] ) ; return static :: $ di -> getOrCreate ( $ class , $ params , $ type ) ; } elseif ( is_callable ( $ type , true ) ) { return static :: $ di -> invoke ( $ type , $ params ) ; } elseif ( is_array ( $ type ) ) { throw new \ Reaction \ DI \ Exceptions \ InvalidConfigException ( 'Object configuration must be an array containing a "class" element.' ) ; } throw new \ Reaction \ DI \ Exceptions \ InvalidConfigException ( 'Unsupported configuration type: ' . gettype ( $ type ) ) ; }
Create instance of class
@param string|array $type Class name or indexed parameters array with key "class"
@param array        $params Constructor parameters indexed array
@return object|mixed
@throws \Reaction\DI\Exceptions\InvalidConfigException(
Create instance of class