/** * 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; }
/** * @param integer[] $address * @param string $output * @dataProvider ipv6Provider2 */ public function testSerializeIPv6($address, $output) { $this->assertSame($output, HostProcessing::serializeIPv6($address)); }