Exemplo n.º 1
0
 /**
  * The URL serializer.
  * @link https://url.spec.whatwg.org/#concept-url-serializer URL Standard
  * @param boolean $excludeFragmentFlag An exclude fragment flag.
  */
 public function serializeURL($excludeFragmentFlag = false)
 {
     $output = $this->scheme . ':';
     if (!is_null($this->host)) {
         $output .= '//';
         if ($this->username !== '' || !is_null($this->password)) {
             $output .= $this->username;
             if (!is_null($this->password)) {
                 $output .= ':' . $this->password;
             }
             $output .= '@';
         }
         $output .= HostProcessing::serializeHost($this->host);
         if (!is_null($this->port)) {
             $output .= ':' . $this->port;
         }
     } elseif (is_null($this->host) && $this->scheme === 'file') {
         $output .= '//';
     }
     $output .= $this->cannotBeABaseURLFlag ? $this->path[0] : '/' . implode('/', $this->path);
     if (!is_null($this->query)) {
         $output .= '?' . $this->query;
     }
     if (!$excludeFragmentFlag && !is_null($this->fragment)) {
         $output .= '#' . $this->fragment;
     }
     return $output;
 }
Exemplo n.º 2
0
 /**
  * @param string|integer[]|null $host
  * @param string $returnValue
  * @dataProvider hostProvider2
  */
 public function testSerializeHost($host, $returnValue)
 {
     $this->assertSame($returnValue, HostProcessing::serializeHost($host));
 }