@param string $type

@throws ConnectionHandlerExceptionImpl

@return Connection
776757
public function getConnection(string $type = null): Connection
    {
        if ($type === null) {
            return $this->getDefaultConnection();
        }
        if (!$this->hasConnectionType($type)) {
            throw new ConnectionHandlerExceptionImpl('Connection not found for type: ' . $type);
        }

        return $this->connections[$type];
    }
712448
public function setContentType(string $contentType): SetContentTypeHandlerInterface
    {
        $this->contentType = $this->normalizeContentType($contentType);
        return $this;
    }
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;
    }
953630
public function forType(string $type): HandlerInterface
    {
        $class = $type !== 'object' ? $type : null;

        if ($class === $this->class) {
            return $this;
        }

        $handler = clone $this;
        $handler->class = $class;

        return $handler;
    }
1159820
public function triggerHandler($type, $exception)
    {
        foreach ($this->handlers[$type] as $handler) {
            $result = call_user_func_array($handler, array($exception, $this->wei));
            if (true === $result) {
                return true;
            }
        }
        return false;
    }
249788
public static function get($type)
    {
        if (!array_key_exists($type, self::$endpoints)) {
            throw new \RuntimeException('Endpoint does not exist.');
        }

        return new self::$endpoints[$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);

		}

	}
895591
public function create(string $type): RenderableElementInterface
    {
        $type = (string) $type;
        $search = strtolower($type);

        if (isset($this->typeToView[$search])) {
            $class = $this->typeToView[$search];

            return new $class();
        } elseif (class_exists($type)) {
            $class = new $type();
            if ($class instanceof RenderableElementInterface) {
                return $class;
            }
        }

        throw new Exception\UnknownTypeException(
            sprintf(
                'The given type "%s" is not an instance of "%s".',
                $type,
                RenderableElementInterface::class
            )
        );
    }
50903
public function setRedirectType($type) {
        if (!is_int($type)) throw new IllegalTypeException('Illegal type of parameter $type: '.gettype($type));

        $this->redirectType = $type;
        return $this;
    }
35317
protected function getLink($type = true) {
        static $links = [];
        $this->config = C('sql');
        $name         = serialize($this->config);
        if (isset($links[$name])) {
            return $this->link = $links[$name];
        }
        try {
            $dns          = $this->getDns();
            $links[$name] = new PDO($dns, $this->config['user'], $this->config['password'], [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"]);
            $links[$name]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $this->execute("SET sql_mode = ''");
            return $this->link = $links[$name];
        } catch (Exception $e) {
            ERRORCODE($e);
        }
    }
744029
private function resolveDatabaseType($type)
    {
        foreach ($this->getDatabases() as $database) {
            if ($database->type === $type) {
                return $database;
            }
        }
        throw new \DomainException(sprintf('Unknown database type (%s). Please use mysqli, pgsql or mariadb.', $type));
    }
888537
public function __cast(string $type)
    {
        if (!isset($this->__delegate)) {
            $this->__createDelegate();
        }

        return $this->__delegate->__cast($type);
    }
746358
public function getFactory(string $type): Closure
    {
        assert(isset($this->closures[$type]));
        return $this->closures[$type];
    }
508745
public function forType(string $type): HandlerInterface
    {
        if ($type !== $this->getType()) {
            throw new LogicException("Unable to use " . get_class($this) . " to cast to $type");
        }
        
        return $this;
    }
833973
public function setType(string $type = self::TYPE_HIDDEN): InputInterface
    {
        $this->type = $type;

        return $this;
    }
755631
public static function getType($type)
    {
        if (!isset(static::$mappedTypeInstances[$type])) {
            if (!static::hasType($type)) {
                throw TypeException::typeDoesNotExist($type);
            }

            static::$mappedTypeInstances[$type] = new static::$mappedTypeClasses[$type]();
        }

        return static::$mappedTypeInstances[$type];
    }
1200629
public static function create($type = self::TYPE_SESSION)
    {
        $class_name = '\\cms\\login\\driver\\' . ucfirst($type) . 'Login';
        if (class_exists($class_name)) {
            try {
                return $class_name::instance();
            } catch (\Exception $e) {}
        }
    }