Snc\RedisBundle\DependencyInjection\Configuration\RedisDsn::parseDsn PHP Method

parseDsn() protected method

protected parseDsn ( string $dsn )
$dsn string
    protected function parseDsn($dsn)
    {
        $dsn = str_replace('redis://', '', $dsn);
        // remove "redis://"
        if (false !== ($pos = strrpos($dsn, '@'))) {
            // parse password
            $password = substr($dsn, 0, $pos);
            if (strstr($password, ':')) {
                list(, $password) = explode(':', $password, 2);
            }
            $this->password = urldecode($password);
            $dsn = substr($dsn, $pos + 1);
        }
        $dsn = preg_replace_callback('/\\?(.*)$/', array($this, 'parseParameters'), $dsn);
        // parse parameters
        if (preg_match('#^(.*)/(\\d+)$#', $dsn, $matches)) {
            // parse database
            $this->database = (int) $matches[2];
            $dsn = $matches[1];
        }
        if (preg_match('#^([^:]+)(:(\\d+))?$#', $dsn, $matches)) {
            if (!empty($matches[1])) {
                // parse host/ip or socket
                if ('/' === $matches[1][0]) {
                    $this->socket = $matches[1];
                } else {
                    $this->host = $matches[1];
                }
            }
            if (null === $this->socket && !empty($matches[3])) {
                // parse port
                $this->port = (int) $matches[3];
            }
        }
    }