Exemplo n.º 1
0
 public function testTranslateKeys()
 {
     $ary = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5);
     $this->assertEquals(array('eno' => 1, 'two' => 2, 'eerht' => 3, 'ruof' => 4, 'five' => 5), \r8\ary\translateKeys($ary, array('one' => 'eno', 'three' => 'eerht', 'four' => 'ruof')));
     $this->assertEquals(array('one' => 1, 'two' => 2, 'six' => 3, 'four' => 4, 'five' => 5), \r8\ary\translateKeys($ary, array('one' => 'five', 'three' => 'six')));
 }
Exemplo n.º 2
0
 /**
  * Imports the settings from a URI
  *
  * @param String $uri The settings to import
  * @return \r8\DB\Config Returns a self reference
  */
 public function fromURI($uri)
 {
     $uri = (string) $uri;
     $result = r8(new \r8\Validator\URL())->validate($uri);
     if (!$result->isValid()) {
         throw new \r8\Exception\Argument(0, "Settings URI", $result->getFirstError());
     }
     $uri = parse_url($uri);
     $uri = \r8\ary\translateKeys($uri, array("user" => "username", "pass" => "password"));
     $this->fromArray($uri);
     if (isset($uri["path"])) {
         $this->setDatabase(ltrim($uri['path'], "/"));
     }
     if (isset($uri["query"])) {
         $this->fromArray(r8(new \r8\QueryParser())->parse($uri['query']));
     }
     return $this;
 }