Normalize the authentication provider class name.

@param  ConfigRepository $config

@return string
776143
protected function normalizeProvider(ConfigRepository $config) : string
    {
        $default = $config->get('auth.providers.users.model');

        if (is_null($default) || trim($default) == '') {
            return \Antvel\Users\Models\User::class;
        }

        return $default;
    }
330499
protected function getDSN(Array $config)
    {
        $dsn = "pgsql:host={$config['host']};dbname={$config['dbname']}";

        if (isset($config['port'])) {
            $dsn .= ";port={$config['port']}";
        }

        if (isset($config['sslmode'])) {
            $dsn .= ";sslmode={$config['sslmode']}";
        }

        return $dsn;
    }
773317
public function authenticate(array $config) {
        if (!$this->client) {
            throw new InvalidArgumentException('The client instance was not given to the application authenticator.');
        }
        if (!array_key_exists('clientId', $config) || !array_key_exists('clientSecret', $config) || !array_key_exists('redirectUri', $config)) {
            throw new InvalidArgumentException('The application authenticator requires a client id, secret and redirect uri.');
        }
        $provider = new Bitbucket([
            'clientId'     => $config['clientId'],
            'clientSecret' => $config['clientSecret'],
            'redirectUri'  => $config['redirectUri']
        ]);
        if (!isset($_GET['code'])) {
            $authUrl = $provider->getAuthorizationUrl();
            \Session::put('oauth2state', $provider->getState());
            header('Location: ' . $authUrl);
            exit;

        } elseif (empty($_GET['state']) || ($_GET['state'] !== \Session::get('oauth2state'))) {
            unset($_SESSION['oauth2state']);
            exit('Invalid state');

        } else {
            $token = $provider->getAccessToken('authorization_code', [
                'code' => $_GET['code']
            ]);
            $this->client->getClient()->addListener(
                new OAuth2Listener(
                    array('access_token' => $token->getToken())
                )
            );
        }
        return $this->client;
    }
95169
protected static function _normalizeName($name)
    {
        $name = ucfirst(strtolower($name));
        $name = str_replace(array('-', '_', '.'), ' ', $name);
        $name = ucwords($name);
        $name = str_replace(' ', '', $name);
        if (stripos($name, 'ZendServer') === 0) {
            $name = 'ZendServer_' . substr($name, strlen('ZendServer'));
        }

        return $name;
    }
661400
private function register_constants( Config $config ) {
		$this->share( 'file', function() use ( $config ) {
			return $config->file;
		} );
		$this->share( 'url', function() use ( $config ) {
			return $config->url;
		} );
		$this->share( 'path', function() use ( $config ) {
			return $config->path;
		} );
		$this->share( 'basename', function() use ( $config ) {
			return $config->basename;
		} );
		$this->share( 'slug', function() use ( $config ) {
			return $config->slug;
		} );
		$this->share( 'version', static::VERSION );
	}
1051558
private function getDsn(array $config)
    {
        $host = isset($config['host']) ? "host={$config['host']};" : '';
        $dsn  = "pgsql:{$host}dbname={$config['database']}";

        if (isset($config['port'])) {
            $dsn .= ";port={$config['port']}";
        }
        if (isset($config['sslmode'])) {
            $dsn .= ";sslmode={$config['sslmode']}";
        }
        if (isset($config['sslcert'])) {
            $dsn .= ";sslcert={$config['sslcert']}";
        }
        if (isset($config['sslkey'])) {
            $dsn .= ";sslkey={$config['sslkey']}";
        }
        if (isset($config['sslrootcert'])) {
            $dsn .= ";sslrootcert={$config['sslrootcert']}";
        }

        return $dsn;
    }
1273359
protected function resolve($config)
    {
        $name = $config['driver'];

        if (isset($this->instances[$name]) && $this->instances[$name]->getConfig() === $config) {
            return $this->instances[$name];
        }

        return $this->instances[$name] = PayMe::make($config);
    }
813693
public static function unwrap($config)
    {
        if (is_callable($config)) {
            $config = $config();
        }
        if ($config instanceof PromiseInterface) {
            $config = $config->wait();
        }
        if ($config instanceof ConfigurationInterface) {
            return $config;
        } elseif (is_array($config) && isset($config['enabled'])) {
            $client_id = isset($config['client_id']) ? $config['client_id']
                : self::DEFAULT_CLIENT_ID;
            $port = isset($config['port']) ? $config['port']
                : self::DEFAULT_PORT;
            return new Configuration($config['enabled'], $port, $client_id);
        }

        throw new \InvalidArgumentException('Not a valid CSM configuration '
            . 'argument.');
    }
644119
private function normalizeCert($cert)
    {
        if (strpos($cert, '-----BEGIN CERTIFICATE-----')===false) {
            $body = trim($cert);
            $cert = '-----BEGIN CERTIFICATE-----'."\n";
            $cert .= wordwrap($body, $this->config['wordwrap'], "\n", true)."\n";
            $cert .= '-----END CERTIFICATE-----'."\n";
        }
        return $cert;
    }
943453
protected function getODMCompilerPass(array $config)
    {
        $nameSpace = 'Gesdinet\JWTRefreshTokenBundle\Document';
        $mappings = array(
            realpath(dirname(__DIR__, 2).'/Resources/config/mongodb/doctrine-mongodb') => $nameSpace,
        );

        if (isset($config['refresh_token_class']) || isset($config['refresh_token_entity'])) {
            $mappings[realpath(dirname(dirname(__DIR__)).'/Resources/config/mongodb/doctrine-superclass')] = $nameSpace;
        } else {
            $mappings[realpath(dirname(dirname(__DIR__)).'/Resources/config/mongodb/doctrine-document')] = $nameSpace;
        }

        return DoctrineMongoDBMappingsPass::createYamlMappingDriver($mappings, array());
    }
67814
public function _defaults($config)
    {
        $env = $config['env'];

        $env->set($env->data() + [
            'SERVER_PROTOCOL' => 'HTTP/1.1',
            'CONTENT_TYPE'    => 'text/html; charset=utf-8',
            'HTTP_HOST'       => 'localhost',
            'SERVER_PORT'     => 80,
            'SCRIPT_NAME'     => '/',
            'REQUEST_URI'     => '/',
            'REQUEST_METHOD'  => 'GET'
        ]);

        list($scheme, $version) = explode('/', $env['SERVER_PROTOCOL']);

        $headers = [];

        if (empty($config['mime'])) {
            $headers['Content-Type'] = $env['CONTENT_TYPE'];
        }

        if (isset($env['CONTENT_LENGTH'])) {
            $headers['Content-Length'] = $env['CONTENT_LENGTH'];
        }

        foreach ($env as $name => $value) {
            if ($name[0] === 'H' && strpos($name, 'HTTP_') === 0) {
                $name = str_replace('_', ' ', substr($name, 5));
                $name = str_replace(' ', '-', ucwords(strtolower($name)));
                $headers[$name] = $value;
            }
        }

        $username = null;
        $password = null;

        $authorization = $env['HTTP_AUTHORIZATION'];

        if (stripos($authorization, 'basic') === 0) {
            $decoded = base64_decode(substr($authorization, strlen('basic ')));
            if (strpos($decoded, ':') !== false) {
                list($username, $password) = explode(':', $decoded, 2);
            }
        } elseif (stripos($authorization, 'digest') === 0) {
            $auth = $config['classes']['auth'];
            $data = $auth::decode(substr($authorization, strlen('digest ')));
            $username = !empty($data['username']) ? $data['username'] : null;
        }

        $defaults = [
            'version'    => $version,
            'scheme'     => strtolower($scheme) . ($env['HTTPS'] ? 's' : ''),
            'host'       => $env['HTTP_HOST'],
            'username'   => $username,
            'password'   => $password,
            'auth'       => null,
            'ignorePath' => null,
            'method'     => $env['REQUEST_METHOD'],
            'headers'    => $headers,
            'env'        => $env
        ];

        $uri = $env['REQUEST_URI'];
        list($path) = explode('?', $uri, 2);
        $path = '/' . trim($path, '/');

        if (isset($env['BASE_PATH'])) {
            $basePath = '/' . trim($env['BASE_PATH'], '/');
            $path = '/' . (trim(substr($path, strlen($basePath)), '/') ?: '/');
        } else {
            $basePath = '/' . trim($env['SCRIPT_NAME'], '/');
            if (strncmp($basePath, $path, strlen($basePath)) === 0) {
                $basename = basename($basePath);
                if (preg_match('~^.*\.php$~', $basename)) {
                    $path = '/' . trim(substr($path, strlen($basePath)), '/');
                    $basePath = '/' . trim(dirname($basePath), '/');
                } else {
                    $basePath = '';
                }
            } else {
                $cut = $i = 0;
                $len = min(strlen($path), strlen($basePath));
                while ($i < $len && $path[$i] === $basePath[$i]) {
                    if ($basePath[$i] === '/') {
                        $cut = $i;
                    }
                    $i++;
                }
                $basePath = substr($path, 0, $cut);
                $path = '/' . (trim(substr($path, $cut), '/') ?: '/');
            }
        }
        return $defaults += [
            'path'     => $path,
            'basePath' => $basePath
        ];
    }
253585
private static function className($configuration)
    {
        $provider = (empty($configuration[Config::PROVIDER]) ? 'null' : $configuration[Config::PROVIDER]);

        if ('null' === $provider) {
            $provider = 'NullStorage';
        }

        return '\\WurflCache\\Adapter\\' . ucfirst($provider);
    }
987086
public static function normalisePermissions($config)
    {
        foreach ($config as $type => $codes) {
            foreach ($codes as $key => $mask) {
                if (is_string($mask)) {
                    $config[$type][$key] = intval($mask, 8);
                }
            }
        }
        return $config;
    }
563414
public static function configure($config)
    {
        if (is_null(static::$instance)) {
            static::$instance = new self();

            static::$name = $config['default'];

            static::$config = $config;
        }

        return static::$instance;
    }
1358321
protected function parseDescriptorField($config)
    {
        if (is_array($config)) {
            $descriptor = [];
            foreach ($config as $field) {
                if (!empty($this->{$field})) {
                    $descriptor[] = $this->{$field};
                }
            }

            return implode(' ', $descriptor);
        } else {
            return $this->{$config};
        }
    }
1059426
public function parseUrl($config)
    {
        $info = [];

        $info['driver'] = $config['driver'];
        $info['hostname'] = $config['host'];
        $info['port'] = isset($config['port']) ? $config['port'] : '';
        $info['username'] = isset($config['username']) ? $config['username'] : null;
        $info['password'] = isset($config['password']) ? $config['password'] : null;
        $info['database'] = isset($config['database']) ? $config['database'] : null;
        $info['charset'] = (isset($config['charset'])) ? $config['charset'] : '';
        $info['collation'] = (isset($config['collation'])) ? $config['collation'] : '';
        $info['prefix'] = (isset($config['prefix'])) ? $config['prefix'] : '';

        if ($info['hostname'] == 'unix(') {
            $socketDb = null;
            $socketDb = $info['hostname'].'/'.$info['database'];
            if (preg_match_all('/^unix\((.+)\)\/(.+)$/', $socketDb, $matches) > 0) {
                $info['hostname'] = $matches[1][0];
                $info['database'] = $matches[2][0];
            }
        }

        self::setConnectionConfig($info['database'], $info);

        return  $info;
    }
1057035
private function mapLaravelToDoctrineConfig($config)
    {
        $default = $config['database.default'];
        $connection = $config["database.connections.{$default}"];
        return App::make(DriverMapper::class)->map($connection);
    }