parse() 공개 정적인 메소드

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.
리턴 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);
 }
예제 #3
0
 /**
  * @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;
 }