123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?php
- namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
- use Psr\Http\Message\UriInterface;
- class Uri implements UriInterface
- {
- private $scheme = '';
- private $userInfo = '';
- private $host = '';
- private $port;
- private $path = '';
- private $query = '';
- private $fragment = '';
- private $uriString;
- public function __construct(string $uri = '')
- {
- $parts = parse_url($uri);
- $this->scheme = $parts['scheme'] ?? '';
- $this->userInfo = $parts['user'] ?? '';
- $this->host = $parts['host'] ?? '';
- $this->port = $parts['port'] ?? null;
- $this->path = $parts['path'] ?? '';
- $this->query = $parts['query'] ?? '';
- $this->fragment = $parts['fragment'] ?? '';
- $this->uriString = $uri;
- }
- public function getScheme(): string
- {
- return $this->scheme;
- }
- public function getAuthority(): string
- {
- if (empty($this->host)) {
- return '';
- }
- $authority = $this->host;
- if (!empty($this->userInfo)) {
- $authority = $this->userInfo.'@'.$authority;
- }
- $authority .= ':'.$this->port;
- return $authority;
- }
- public function getUserInfo(): string
- {
- return $this->userInfo;
- }
- public function getHost(): string
- {
- return $this->host;
- }
- public function getPort(): ?int
- {
- return $this->port;
- }
- public function getPath(): string
- {
- return $this->path;
- }
- public function getQuery(): string
- {
- return $this->query;
- }
- public function getFragment(): string
- {
- return $this->fragment;
- }
-
- public function withScheme($scheme)
- {
- throw new \BadMethodCallException('Not implemented.');
- }
-
- public function withUserInfo($user, $password = null)
- {
- throw new \BadMethodCallException('Not implemented.');
- }
-
- public function withHost($host)
- {
- throw new \BadMethodCallException('Not implemented.');
- }
-
- public function withPort($port)
- {
- throw new \BadMethodCallException('Not implemented.');
- }
-
- public function withPath($path)
- {
- throw new \BadMethodCallException('Not implemented.');
- }
-
- public function withQuery($query)
- {
- throw new \BadMethodCallException('Not implemented.');
- }
-
- public function withFragment($fragment)
- {
- throw new \BadMethodCallException('Not implemented.');
- }
- public function __toString(): string
- {
- return $this->uriString;
- }
- }
|