parse() public static method

When using the "redis" and "rediss" schemes the URI is parsed according to the rules defined by the provisional registration documents approved by IANA. If the URI has a password in its "user-information" part or a database number in the "path" part these values override the values of "password" and "database" if they are present in the "query" part.
public static parse ( string $uri ) : array
$uri string URI string.
return array
    /**
     * {@inheritdoc}
     */
    public function register(Container $app)
    {
        $prefix = $this->prefix;

        $app["$prefix.default_parameters"] = array();
        $app["$prefix.default_options"] = array();

        $app["$prefix.uri_parser"] = $app->protect(function ($uri) {
            return Parameters::parse($uri);
        });

        $app["$prefix.client_constructor"] = $app->protect(function ($parameters, $options) {
            return new Client($parameters, $options);
        });

        $app["$prefix.client_initializer"] = $this->getClientInitializer($app, $prefix);
        $app["$prefix"] = $this->getProviderHandler($app, $prefix);
    }
示例#2
0
文件: Factory.php 项目: nrk/predis
 /**
  * Creates a connection parameters instance from the supplied argument.
  *
  * @param mixed $parameters Original connection parameters.
  *
  * @return ParametersInterface
  */
 protected function createParameters($parameters)
 {
     if (is_string($parameters)) {
         $parameters = Parameters::parse($parameters);
     } else {
         $parameters = $parameters ?: array();
     }
     if ($this->defaults) {
         $parameters += $this->defaults;
     }
     return new Parameters($parameters);
 }
 /**
  * @group disconnected
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Invalid parameters URI: tcp://invalid:uri
  */
 public function testParsingURIThrowOnInvalidURI()
 {
     Parameters::parse('tcp://invalid:uri');
 }
示例#4
0
 /**
  * Creates a new connection to a sentinel server.
  *
  * @return NodeConnectionInterface
  */
 protected function createSentinelConnection($parameters)
 {
     if ($parameters instanceof NodeConnectionInterface) {
         return $parameters;
     }
     if (is_string($parameters)) {
         $parameters = Parameters::parse($parameters);
     }
     if (is_array($parameters)) {
         // We explicitly set "database" and "password" to null,
         // so that no AUTH and SELECT command is send to the sentinels.
         $parameters['database'] = null;
         $parameters['password'] = null;
         if (!isset($parameters['timeout'])) {
             $parameters['timeout'] = $this->sentinelTimeout;
         }
     }
     $connection = $this->connectionFactory->create($parameters);
     return $connection;
 }