コード例 #1
0
ファイル: Uri.php プロジェクト: codeblanche/web
 /**
  * Import from an array
  *
  * @param array $array
  *
  * @return Uri
  */
 protected function fromArray($array)
 {
     if (empty($array)) {
         return $this;
     }
     $this->query = new QueryString();
     if (!empty($array['query'])) {
         $this->query->import($array['query']);
     }
     $keys = array('scheme', 'host', 'port', 'user', 'pass', 'path', 'fragment', 'dirname', 'basename', 'extension', 'filename');
     foreach ($keys as $key) {
         if (!isset($array[$key])) {
             continue;
         }
         $this->{$key} = $array[$key];
         if ($key === 'path') {
             $this->parsePath($this->path);
         }
     }
     $this->buildPath();
     return $this;
 }
コード例 #2
0
ファイル: QueryStringTest.php プロジェクト: codeblanche/web
 public function testToString()
 {
     $this->queryString->import($this->array);
     $this->assertEquals($this->string, (string) $this->queryString);
 }