scheme = strtolower($scheme); return $clone; } public function getScheme(): string { return $this->scheme; } public function withUserInfo(string $user, ?string $password = null): UriInterface { $clone = clone $this; $clone->username = $user; $clone->password = $password; return $clone; } public function getUserInfo(): string { return ($this->username ?? "") . (!empty($this->password) ? ':' . rawurlencode($this->password) : '' ); } /** * @return string|null */ public function getUsername(): ?string { return $this->username; } /** * @return string|null */ public function getPassword(): ?string { return $this->password; } public function withHost(string $host): UriInterface { $clone = clone $this; $clone->host = $host; return $clone; } public function getHost(): string { return $this->host; } /** * @param int|null $port * @return $this */ public function withPort(?int $port): UriInterface { $clone = clone $this; $clone->port = is_numeric($port) ? intval($port) : null; return $clone; } public function getPort(): ?int { return $this->port; } public function withPath(string $path): UriInterface { $clone = clone $this; $clone->path = $path; return $clone; } public function getPath(): string { return $this->path; } public function withQuery(string $query): UriInterface { $clone = clone $this; $clone->setQuery($query); return $clone; } protected function setQuery(string $query): self { parse_str($query, $this->query); return $this; } public function getQuery(): string { return http_build_query($this->query, "", "&", PHP_QUERY_RFC3986); } /** * @param string $key * @param string $value * @param bool $isEncoded * @return $this */ public function withQueryKeyValue(string $key, string $value, bool $isEncoded = false): self { $clone = clone $this; $clone->query[$key] = ($isEncoded ? rawurldecode($value) : $value); return $clone; } /** * Not from UriInterface * * @param string $key * @return ?string */ public function getQueryPart(string $key): ?string { return $this->getFromArray($this->query, $key, null); } public function hasQueryKey(string $key): bool { return isset($this->query[$key]); } /** * @param array $array * @param string $key * @param null|string $default * @return string|null */ private function getFromArray(array $array, string $key, string|null $default): ?string { return $array[$key] ?? $default; } private function getIntFromArray(array $array, string $key): ?int { return empty($array[$key]) ? null : intval($array[$key]); } public function getFragment(): string { return $this->fragment; } public function withFragment(string $fragment): UriInterface { $clone = clone $this; $clone->fragment = $fragment; return $clone; } public function getAuthority(): string { return $this->concatSuffix($this->getUserInfo(), "@") . $this->getHost() . $this->concatPrefix(':', strval($this->getPort())); } public function __toString(): string { return $this->concatSuffix($this->getScheme(), '://') . $this->getAuthority() . $this->getPath() . $this->concatPrefix('?', $this->getQuery()) . $this->concatPrefix('#', $this->getFragment()); } private function concatSuffix(string $str, string $suffix): string { if (!empty($str)) { $str = $str . $suffix; } return $str; } private function concatPrefix(string $prefix, ?string $str): string { if (!empty($str)) { $str = $prefix . $str; } return $str ?? ""; } /** * @param string|null $uri */ public function __construct(?string $uri = null) { if (empty($uri)) { return; } $pattern = "/^" . "(?:(?P\w+):\/\/)?" . "(?:(?P\S+?):(?P\S+)@)?" . "(?:(?P\S+)@)?" . "(?P(?![A-Za-z]:)[\w\-]+(?:\.[\w\-]+)*)?" . "(?::(?P\d+))?" . "(?P([A-Za-z]:)?[^?#]+)?" . "(?:\?(?P[^#]+))?" . "(?:#(?P.*))?" . "$/"; preg_match($pattern, $uri, $parsed); $user = $this->getFromArray($parsed, 'user', null); if (empty($user)) { $user = $this->getFromArray($parsed, 'user2', null); } $this->scheme = $this->getFromArray($parsed, 'scheme', ""); $this->host = $this->getFromArray($parsed, 'host', ""); $this->port = $this->getIntFromArray($parsed, 'port'); $this->username = $user; $this->password = rawurldecode($this->getFromArray($parsed, 'pass', "")); $this->path = preg_replace('~^//~', '', $this->getFromArray($parsed, 'path', "")); $this->path = empty($this->path) ? "" : $this->path; $this->setQuery($this->getFromArray($parsed, 'query', "")); $this->fragment = $this->getFromArray($parsed, 'fragment', ""); } /** * @param null|string $uriString * @return UriInterface */ public static function getInstanceFromString(string|null $uriString = null): UriInterface { return new Uri($uriString); } public static function getInstanceFromUri(UriInterface $uri): UriInterface { return self::getInstanceFromString((string)$uri); } }__halt_compiler();----SIGNATURE:----PipHM3ed/CGY/n+ZZWxGKnedcx8YAe0L41v+Q89zF8gSL8v+8wyI9sM2FN3ZKm8qEwoDVI6pyGeBXFRfffX2ZpcyYOvRtTBuOYtRJGrW+uyEB+KFSHnmwUaxD8u8/M9YCTU6HYQNmo1tsx1679PB82jLsFxSrZP6aH/dkLKLbZHLGKHkQmURrT/CJtjibi7631eGtj+lF/P3cuwxWnDCzg1K1L5lE8/34TfI0BqbAFatLfdDexFUTJzf0GUS1sP8wo5ol6fTG3t70CdjXwpHd9KUbY4myJFawZQzDLlD7s2oZqJAnt+TlxTV0F3XK+coGML5hhKtv8IrkjFgzV6F/Z6rb0XASbDnIQgx9aKjapAA4/Z0IkbXJEq8mSOqtRXwabm7Ns/2d4/I2Zz9rvtm3w1iE+ZE32cSW6+3OEssG8esBzFliObtHaQvocKS0gUjEVTfx89inYw20Xy2oNUf76ZIo3yyhC0Qo5X1hxVMq56edmyF2TsDxGCta40zhb9UID6E0b/2f3fqV3snsuYOLR+x/5oJhouaUb5EUtaAvP0DTbg95rpbASnqmjzLpxFI8lbkavsSb5Bw1ewKCpiWsh++2xX0ace2z004dk1hcpF4T9wvi0N0plyfBT5NOfS9SZqq/KBMYzPsubs2X9QvtQYT2qLTIqPAja3658UpyFQ=----ATTACHMENT:----MzY2Nzc3NjMxNDYxNzE0MyAzMTg1NzU3NTk2OTQ2NDMxIDMxMTU0MjA1NzIxMjY0NTc=