Example #1
0
 /**
  * Returns a URI string describing this connection
  *
  * @return String
  */
 public function getURI()
 {
     $uri = new \r8\URL();
     $uri->setScheme("db")->setUserName($this->username)->setPassword($this->password)->setHost($this->host)->setPort($this->port)->setPath($this->database)->setQuery(array_filter(array("persistent" => $this->persistent ? "t" : NULL, "forceNew" => $this->forceNew ? "t" : NULL)));
     return $uri->__toString();
 }
Example #2
0
 /**
  * Private method for building the URL object
  *
  * @return \r8\URL
  */
 private function buildURL()
 {
     $url = new \r8\URL();
     // Get the url Scheme from the server protocol
     if (self::hasKey($this->server, "SERVER_PROTOCOL")) {
         $url->setScheme(strtolower(strstr($this->server['SERVER_PROTOCOL'], "/", TRUE)));
     }
     // Pull the server host, if it is set
     if (self::hasKey($this->server, 'HTTP_HOST')) {
         $url->setHost($this->server['HTTP_HOST']);
     } else {
         if (self::hasKey($this->server, "SERVER_ADDR")) {
             $url->setHost($this->server['SERVER_ADDR']);
         }
     }
     // Pull the port
     if (self::hasKey($this->server, "SERVER_PORT")) {
         $url->setPort((int) $this->server['SERVER_PORT']);
     }
     // The path and file name
     if (self::hasKey($this->server, 'SCRIPT_NAME')) {
         $url->setPath($this->server['SCRIPT_NAME']);
     }
     // The faux directories
     if (self::hasKey($this->server, 'PATH_INFO')) {
         $url->setFauxDir(\r8\str\head($this->server['PATH_INFO'], "/"));
     }
     // Finally, pull the the URL query
     if (self::hasKey($this->server, 'QUERY_STRING')) {
         $url->setQuery($this->server['QUERY_STRING']);
     }
     return $url;
 }
Example #3
0
 public function testCopyURL()
 {
     $url = new \r8\URL();
     $this->assertSame($url, $url->copyURL(new \r8\URL()));
     $this->assertNull($url->getURL());
     $source = new \r8\URL("http://*****:*****@test.example.com:40/path/to/file.php?var=value#frag");
     $source->setFauxDir("/test/faux/dirs");
     $this->assertSame($url, $url->copyURL($source));
     $this->assertSame("http://*****:*****@test.example.com:40/path/to/file.php/test/faux/dirs?var=value#frag", $url->getURL());
 }