Get adapter class from argument.

@param string $argument Given argument

@return string

@throws AdapterException When given adapter class doesn't exist
503298
private function getAdapterClassFromArgument($argument)
    {
        if (!class_exists($adapterClass = $argument) &&
            !class_exists($adapterClass = '\\Sly\\NotificationPusher\\Adapter\\' . ucfirst($argument))) {
            throw new AdapterException(
                sprintf(
                    'Adapter class %s does not exist',
                    $adapterClass
                )
            );
        }

        return $adapterClass;
    }
928290
protected static function getAdapter(?string $adapter = null): AbstractMailAdapter
    {
        $config = static::getConfig();

        if (static::$firstKey === null) {
            static::$firstKey = $config->getFirstKey();
        }

        $key = $adapter ?? static::$firstKey;
        $configArray = $config->get($key, []);

        if (($configArray['enabled'] ?? false) === true) {
            if (isset($configArray['module'])) {
                Application::registerModule($configArray['module']);
            }

            $className = $configArray['adapter_class'] ?? null;

            if ($className === null) {
                throw new ConfigException("Key 'adapter_class' is not set in mail config={$key}");
            }

            if (!class_exists($className, true)) {
                throw new ConfigException("Unknown mail class={$className} under key={$adapter}");
            }

            return new $className($configArray['options'] ?? []);
        }

        return new Simulate($configArray['options'] ?? []);
    }
868593
public function defaultAdapter($adapterKey)
    {
        $exists = false;
        if (in_array($adapterKey, $this->rendererAdapters->keys())) {
            $this->defaultAdapter = $adapterKey;
            $exists = true;
        }

        return $exists;
    }
765937
public static function setAdapter($adapter)
    {
        switch (strtolower($adapter)) {
            case 'sodium':
                $adapterSet = '\Zest\Encryption\Adapter\SodiumEncryption';
                break;
            case 'openssl':
                $adapterSet = '\Zest\Encryption\Adapter\OpenSslEncryption';
                break;
            default:
                $adapterSet = '\Zest\Encryption\Adapter\OpenSslEncryption';
                break;
        }
        $key = __config()->encryption->key;
        self::$adapter = new $adapterSet($key);

        return __CLASS__;
    }
477104
public function getAdapter(string $name): AdapterInterface
    {
        if (!$this->hasAdapter($name)) {
            throw new Exception\AdapterNotFound('auth adapter '.$name.' is not registered');
        }

        return $this->adapter[$name];
    }
280435
private function getMethodArgument($argument)
    {
        $arg = '__unknown__';
        if ($argument instanceof PyStringNode) {
            $arg = 'PyStringNode $string';
        } elseif ($argument instanceof TableNode) {
            $arg = 'TableNode $table';
        }

        return $arg;
    }
264596
public static function getAdapter(string $adapter = null): AbstractCacheAdapter
    {
        $key = $adapter ?? static::getConfig()->getFirstKey();

        if (isset(static::$adapters[$key])) {
            return static::$adapters[$key];
        }

        $config = static::getConfig();
        $configArray = $config->get($key, []);

        if (($configArray['enabled'] ?? false) === false) {
            static::$adapters[$key] = new Cache\Adapter\DevNull([]);
        } else {

            if (isset($configArray['module'])) {
                Application::registerModule($configArray['module']);
            }

            $className = $configArray['adapter_class'] ?? null;

            if ($className === null) {
                throw new ConfigException("Cache config under key={$key} doesn\'t have defined 'adapter_class'; please set the 'adapter_class' with the name of class that extends \\Koldy\\Cache\\Adapter\\AbstractCacheAdapter");
            }

            if (!class_exists($className, true)) {
                throw new ConfigException("Class={$className} defined in cache config under key={$adapter} wasn't found; check the name and namespace of class and if class can be loaded");
            }

            static::$adapters[$key] = new $className($configArray['options'] ?? []);
        }

        return static::$adapters[$key];
    }
2513
private static function getAdapterClassName($adapterName)
    {
        $className = 'Piwik\Db\Adapter\\' . str_replace(' ', '\\', ucwords(str_replace(array('_', '\\'), ' ', strtolower($adapterName))));
        if (!class_exists($className)) {
            throw new \Exception(sprintf("Adapter '%s' is not valid. Maybe check that your Matomo configuration files in config/*.ini.php are readable by the webserver.", $adapterName));
        }
        return $className;
    }
1138122
protected function switchType($argument)
    {
        $stringType = null;
        $type       = strtolower(gettype($argument));

        switch ($type) {
            case 'boolean':
                $stringType = sprintf(
                    '[%s "%s"]', ucwords($type),
                    ((int) $argument === 1) ? 'True' : 'False'
                );
                break;
            case 'integer':
            case 'double':
            case 'float':
            case 'string':
                $stringType = sprintf('[%s "%s"]', ucwords($type), $argument);
                break;
            case 'array':
                $stringType = sprintf(
                    '[%s {value: %s}]', ucwords($type), var_export($argument, true)
                );
                break;
            case 'object':
                $stringType = sprintf('[%s "%s"]', ucwords($type), get_class($argument));
                break;
            case 'resource':
                $stringType = sprintf('[%s]', ucwords($type));
                break;
            case 'null':
                $stringType = '[NULL]';
                break;
            default;
                $stringType = '[Unknown Type]';
                break;
        }

        return $stringType;
    }
49292
public static function gaufretteFactory(array $adapter) {
		$class = $adapter['adapterClass'];
		$Reflection = new ReflectionClass($class);

		if (!is_array($adapter['adapterOptions'])) {
			throw new InvalidArgumentException(sprintf('%s: The adapter options must be an array!', $configName));
		}

		$adapterObject = $Reflection->newInstanceArgs($adapter['adapterOptions']);

		return new $adapter['class']($adapterObject);
	}
36812
protected function arguments(array $arguments = null)
    {
        return is_null($arguments)
            ? $this->arguments
            : ($this->arguments = $arguments);
    }
1035032
protected function callSupportDisplayer($abstract, $arguments)
    {
        return $this->display(function ($value) use ($abstract, $arguments) {
            if (is_array($value) || $value instanceof Arrayable) {
                return call_user_func_array([collect($value), $abstract], $arguments);
            }

            if (is_string($value)) {
                return call_user_func_array([Str::class, $abstract], array_merge([$value], $arguments));
            }

            return $value;
        });
    }
449053
protected function firstArgumentCorrespondsToPolicy(array $arguments)
    {
        if (! isset($arguments[0])) {
            return false;
        }

        $argument = $arguments[0];

        if (is_object($argument)) {
            $class = get_class($argument);

            return isset($this->policies[$class]);
        }

        return is_string($argument) && isset($this->policies[$argument]);
    }
49947
private function createArgumentDescriptorForMagicMethod($argument)
    {
        $argumentType = null;
        $argumentName = null;
        $argumentDefault = false; // false means we have not encountered the '=' yet.
        foreach ($argument as $part) {
            $part = trim($part);
            if (!$part) {
                continue;
            }

            // Type should not be assigned after name
            if (!$argumentName && !$argumentType && $part{0} != '$') {
                $argumentType = $part;
            } elseif (!$argumentName && $part{0} == '$') {
                $argumentName = $part;
            } elseif ($part == '=') {
                $argumentDefault = null;
            } elseif ($argumentDefault === null) {
                $argumentDefault = $part;
            }
        }
        if ($argumentDefault === false) {
            $argumentDefault = null;
        }

        // if no name is set but a type is then the input is malformed and we correct for it
        if ($argumentType && !$argumentName) {
            $argumentName = $argumentType;
            $argumentType = null;
        }

        // if there is no type then we assume it is 'mixed'
        if (!$argumentType) {
            $argumentType = 'mixed';
        }

        $argumentDescriptor = new ArgumentDescriptor();
        $argumentDescriptor->setTypes($this->builder->buildDescriptor(new Collection(array($argumentType))));
        $argumentDescriptor->setName($argumentName[0] == '$' ? $argumentName : '$' . $argumentName);
        $argumentDescriptor->setDefault($argumentDefault);

        return $argumentDescriptor;
    }
665565
public static function getInstance($adapter)
	{
		// Only create one stemmer for each adapter.
		if (isset(self::$instances[$adapter]))
		{
			return self::$instances[$adapter];
		}

		// Setup the adapter for the stemmer.
		$class = '\\Joomla\\Language\\Stemmer\\' . ucfirst(trim($adapter));

		// Check if a stemmer exists for the adapter.
		if (!class_exists($class))
		{
			// Throw invalid adapter exception.
			throw new RuntimeException(sprintf('Invalid stemmer type %s', $adapter));
		}

		self::$instances[$adapter] = new $class;

		return self::$instances[$adapter];
	}
34326
protected function getAdapter() : AdapterInterface
    {
        if ($this->adapter === null) {
            $databaseFile = $this->getTemporaryFileName();
            $adapter = AdapterFactory::getInstance($databaseFile);
            $this->setAdapter($adapter);
        }

        return $this->adapter;
    }
896206
public function get($key)
    {
        if (!isset($this->elements[$key])) {
            throw new InvalidArgumentException('Adapter does not exist');
        }

        return $this->elements[$key];
    }