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:----ABIwavatQop3czJ3oNUOB3Ys2mq8QUPjMy1FK+UXlG9pMX/jP4JL2i2KfxZiHGUVFvNSuAXQs5a44bCQ72hor+rmo1ZfNc55Zvog4pry8r4HWXHegzRwGLy+y2JraTc2g9jsz6IDfsg67z0tjWP2OiLeX5e6iJ3+xbfnhG7l0KfiTTdHNIJckZV+BUUWuGKLQs+gs6fQQn1fg9r7bC+MsgjKu6/Hf3rw4F9Vo98yuplIicU0Up9mv8EO1nw2Yc3UnzAUhto761czF1HqrD5NZNdvBnzGZLw3sG3HRx//XL1uteQvftEGCefnfywLReUTdeYDRIxYv3rXxs9qPUxLchznkyzE1Z5uJT9Vq+ObuRJ/X9aPaB8oSMqaRf4BFXzt22Ysix6H16L+AtR4DFPHOT7bL7uCLedLXUFZwXqR3jVD+yqRxVEtcJjMP3mAigPy7aR5XuvacfFXKviI8gbxCX6gbGTPN7iypNGumAM8O9GQwfXlJQ5e3hxP0BpAII4uAOHaA4YfPNtzYDDV3Ddsc3BfJ3QHGsKGwDgXCYiB3rSfpDa0ijfy80bhl0cmU62PiHKF/fMyNRfIOhVhPLwy7Jj7kuJKCDWU1OdYaCzIwljRbt+tO0EKvCRrHHNhTuyyESqcgWYPN7f8SWULjaGYjIl3u2NgEyhw6Qum8gBFot8=----ATTACHMENT:----MzU3Nzc1NTUzOTMxNzc3OCAzODk4NjI2MTk4NDYyMjMyIDIzMjU1OTcwMDI1MDg4NTE=