@param string $type
@param array  $args

@return FunctionProviderInterface|null

@throws Exception\ErrorCreatingFunctionException
973995
public function getFunction($type, array $args = [])
    {
        try {
            $wrapper = $this->wrapperFactory($type, $args, ServiceTypeResolver\FunctionWrapper::class);
        } catch (\Exception $e) {
            throw new Exception\ErrorCreatingFunctionException($e->getMessage(), $e->getCode(), $e);
        }
        return $wrapper;
    }
1252150
public function select(string $type = null)
    {
        if (empty($type)) {
            $type = $this->provider;
        }

        $providers = $this->mergeProviders();
        if (!isset($providers[$type])) {
            throw new InvalidArgumentException(sprintf('Provider %s does not exist', $type));
        }

        $providerBeanName = $providers[$type];

        return App::getBean($providerBeanName);
    }
1197552
protected static function _log($type, array $args)
    {
        // nothing passed in, don't do anything
        if (count($args) == 0 && $type != self::GROUP_END) {
            return;
        }

        $logger = self::getInstance();

        $logger->_processed = array();

        $logs = array();
        foreach ($args as $arg) {
            $logs[] = $logger->_convert($arg);
        }

        $backtrace = debug_backtrace(false);
        $level = $logger->getSetting(self::BACKTRACE_LEVEL);

        $backtrace_message = 'unknown';
        if (isset($backtrace[$level]['file']) && isset($backtrace[$level]['line'])) {
            $backtrace_message = $backtrace[$level]['file'] . ' : ' . $backtrace[$level]['line'];
        }

        $logger->_addRow($logs, $backtrace_message, $type);
    }
510080
protected function create($type)
	{
		if ( !isset($this->browserConfigurations[$type]) ) {
			throw new \InvalidArgumentException('Browser configuration type "' . $type . '" not registered');
		}

		return clone $this->browserConfigurations[$type];
	}
735106
public function scope($view, $args = array(), $type = null)
    {
        $viewDir = $this->getConfig('containerDir.view');

        // Add namespace to find in a theme path.
        $path = $this->getThemeNamespace($viewDir.'.'.$view);

        return $this->of($path, $args, $type);
    }
35565
protected function resolve($type, $name, $registry, array $args = array())
    {
        if($registry instanceof \Closure)
            return call_user_func_array($registry->bindTo($this), $args);

        if(is_string($registry)) {
            if($type == 'service')
                return $this->instantiate($registry);
            else
                return $this->instantiate($registry, $args);
        }

        // assume index 0 as class name
        if(is_array($registry))
        {
            $class = $registry[0];

            $arguments = array();

            // argument passed
            if(isset($registry[1]))
            {
                // the second element isn't an array
                if(!is_array($registry[1]))
                    throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Second value for array based ['.$name.'] registry must be an array');

                foreach($registry[1] as $arg)
                {
                    // if isn't string. allow only string.
                    if(!is_string($arg))
                        throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Argument for array based ['.$name.'] registry must be string');

                    if($arg = $this->tokenResolve($arg))
                        $arguments[] = $arg;
                }
            }

            // merge with the one passed
            $arguments = array_merge($arguments, $args);

            return $this->instantiate($class, $arguments);
        }

        throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Unable to resolve the ['.$name.'] registry');
    }
468607
public function invoke($type, $parameters = null)
    {
        $class = $this->getClass($type);
        $name  = $this->normalizeType($type);

        $params = func_get_args();
        array_shift($params);

        $reflector = new \ReflectionClass($class);
        $instance  = $reflector->newInstanceArgs($params);

        if (empty($params)) {
            parent::__set($name, $instance);
        }

        return (clone $instance);
    }
498084
public function scopeWithLayout($view, $args = array(), $type = null)
    {
        $view = $this->getLayoutName().'.'.$view;

        return $this->scope($view, $args, $type);
    }
1045338
protected function call( $type, $params ) {
		if ( !isset( $this->callbacks[$type] ) ) {
			return;
		}
		foreach ( $this->callbacks[$type] as $callback ) {
			if ( is_callable( $callback ) ) {
				call_user_func_array( $callback, $params );
			}
		}
	}
638969
protected function createType($type, $options = array())
	{
		$type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type);

		$class = __NAMESPACE__ . '\\Type\\' . ucfirst($type);

		if (!class_exists($class))
		{
			throw new InvalidArgumentException("Type [$type] not supported.");
		}

		return new $class($options);
	}
828429
public function create($type)
    {
        $typeOptions    = $this->getOption(self::OPTION_MAPPERS);
        $typeOption     = isset($typeOptions[$type]) ? $typeOptions[$type] : $this->throwException();
        $importerString = isset($typeOption[self::OPTION_MAPPERS_IMPORTER]) ? $typeOption[self::OPTION_MAPPERS_IMPORTER] : $this->throwException();
        $importer       = $this->buildService($importerString, ImportServiceInterface::class);

        if (isset($typeOption[self::OPTION_MAPPERS_MAPPER])) {
            $mapperString = $typeOption[self::OPTION_MAPPERS_MAPPER];
            $mapper       = $this->buildService($mapperString);
        } else {
            $mapper = $this->getDefaultMapper();
        }

        $this->propagate($mapper);
        $importer->setMapper($mapper);

        return $importer;
    }
809622
public function withArgs($args = [])
    {
        if (!is_array($args)) {
            $args = func_get_args();
        }

        $this->args = $args;
        return $this;
    }
1010452
public function create( $type, array $properties = [ ] ) {

		$type = (string) $type;

		if ( isset( $this->classes[ $type ] ) ) {
			$class = $this->classes[ $type ];

			return new $class( $properties );
		} else if ( class_exists( $type ) ) {
			$class = new $type( $properties );
			if ( $class instanceof FilterInterface ) {

				return $class;
			}
		}

		throw new Exception\InvalidArgumentException(
			sprintf(
				'The given class <code>%s</code> does not exists.',
				$type
			)
		);

	}
470202
public static function create($type = null, array $config = []) {

	    if(!$type) {

	        if(!isset($config['dsn'])) {
	            throw new \Exception('No database type defined.');
            }

            if(preg_match('/^([a-z0-9]+):/i', trim($config['dsn']), $matches)) {
                $type = $matches[1];
            }
            else {
                throw new \Exception('No driver found in DSN.');
            }

        }

		$type = strtolower($type);

		if($type === 'propel') {

			// check whether Propel is available (assume Propel2)

            if(!class_exists('\\Propel\\Runtime\\Propel')) {
                throw new \Exception('Propel is configured as driver for vxPDO but not available in this application.');
            }

            $serviceContainer = \Propel\Runtime\Propel::getServiceContainer();

            // retrieve adapter information

            $adapterName = $serviceContainer->getAdapterClass();
            $dsnName = $serviceContainer->getDefaultDatasource();

            /* @var $connection \Propel\Runtime\Connection\ConnectionInterface */

            $connection = \Propel\Runtime\Propel::getConnection();

            if(!in_array($adapterName, ['mysql', 'pgsql'])) {

                throw new \Exception(sprintf("vxPDO accepts only mysql and pgsql as established connection drivers. The configured Propel connection '%s' uses '%s'.", $dsnName, $adapterName));

			}

			// @todo fugly like hell - perhaps some more concise solution exists

            preg_match('/dbname=([^;]+)/i', \Propel\Runtime\Propel::getConnectionManager($dsnName)->getConfiguration()['dsn'], $matches);
            $dbName = $matches[1] ?? '';

            $pdoConnection = new Propel2ConnectionWrapper($connection);
            $pdoConnection->setName($dsnName);
            $pdoConnection->setDbName($dbName);

            $className =
                __NAMESPACE__ .
                '\\Adapter\\' .
                ucfirst($adapterName);

            /* @var $vxPDO DatabaseInterface */

            $vxPDO = new $className();
            $vxPDO->setConnection($pdoConnection);

            return $vxPDO;

		}

		else {

			$className =
				__NAMESPACE__ .
				'\\Adapter\\' .
				ucfirst($type);
	
			// check whether driver is available
				
			if(!class_exists($className)) {
	
				throw new ConfigException(sprintf("No class for driver '%s' supported.", $type));
	
			}
				
			return new $className($config);

		}

	}
280088
public function build($type)
    {
        if (!is_subclass_of($type, BaseSunat::class)) {
            throw new \Exception($type.' should be instance of '.BaseSunat::class);
        }

        /** @var $service BaseSunat */
        $service = new $type();
        $service->setClient($this->client);

        return $service;
    }
313891
private function __setCallback($type, $class, array $args)
    {
        if (!is_array($class)) {
            $this->{$type} = [
                [
                    'class' => $class,
                    'args' => $args
                ]
            ];

            return $this;
        } elseif (is_array($class) && count($class) == 2) {
            $className = $class[0];
            $methodName = $class[1];
        } else {
            if (is_array($class)) {
                $class = implode($class);
            }
            throw new \InvalidArgumentException("{$class} is missformated");
        }

        $this->{$type} = [
            [
                'class' => [$className, $methodName],
                'args' => $args
            ]
        ];

        return $this;
    }
326470
protected static function createInstance(array $args = [])
    {
        if (!self::$reflection) {
            self::$reflection = new \ReflectionClass('IntlDateFormatter');
        }

        $instance = self::$reflection->newInstanceArgs($args);

        self::checkInternalClass($instance, '\IntlDateFormatter', $args);

        return $instance;
    }