4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
14 use Psr\Http\Message\UriInterface;
17 * @author Rougin Royce Gutib <rougingutib@gmail.com>
19 class Uri implements UriInterface
22 private $userInfo = '';
27 private $fragment = '';
30 public function __construct($uri = '')
32 $parts = parse_url($uri);
34 $this->scheme = isset($parts['scheme']) ? $parts['scheme'] : '';
35 $this->userInfo = isset($parts['user']) ? $parts['user'] : '';
36 $this->host = isset($parts['host']) ? $parts['host'] : '';
37 $this->port = isset($parts['port']) ? $parts['port'] : null;
38 $this->path = isset($parts['path']) ? $parts['path'] : '';
39 $this->query = isset($parts['query']) ? $parts['query'] : '';
40 $this->fragment = isset($parts['fragment']) ? $parts['fragment'] : '';
41 $this->uriString = $uri;
44 public function getScheme()
49 public function getAuthority()
51 if (empty($this->host)) {
55 $authority = $this->host;
57 if (!empty($this->userInfo)) {
58 $authority = $this->userInfo.'@'.$authority;
61 $authority .= ':'.$this->port;
66 public function getUserInfo()
68 return $this->userInfo;
71 public function getHost()
76 public function getPort()
81 public function getPath()
86 public function getQuery()
91 public function getFragment()
93 return $this->fragment;
96 public function withScheme($scheme)
98 throw new \BadMethodCallException('Not implemented.');
101 public function withUserInfo($user, $password = null)
103 throw new \BadMethodCallException('Not implemented.');
106 public function withHost($host)
108 throw new \BadMethodCallException('Not implemented.');
111 public function withPort($port)
113 throw new \BadMethodCallException('Not implemented.');
116 public function withPath($path)
118 throw new \BadMethodCallException('Not implemented.');
121 public function withQuery($query)
123 throw new \BadMethodCallException('Not implemented.');
126 public function withFragment($fragment)
128 throw new \BadMethodCallException('Not implemented.');
131 public function __toString()
133 return $this->uriString;