Version 1
[yaffs-website] / vendor / symfony / psr-http-message-bridge / Tests / Fixtures / Uri.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
13
14 use Psr\Http\Message\UriInterface;
15
16 /**
17  * @author Rougin Royce Gutib <rougingutib@gmail.com>
18  */
19 class Uri implements UriInterface
20 {
21     private $scheme = '';
22     private $userInfo = '';
23     private $host = '';
24     private $port;
25     private $path = '';
26     private $query = '';
27     private $fragment = '';
28     private $uriString;
29
30     public function __construct($uri = '')
31     {
32         $parts = parse_url($uri);
33
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;
42     }
43
44     public function getScheme()
45     {
46         return $this->scheme;
47     }
48
49     public function getAuthority()
50     {
51         if (empty($this->host)) {
52             return '';
53         }
54
55         $authority = $this->host;
56
57         if (!empty($this->userInfo)) {
58             $authority = $this->userInfo.'@'.$authority;
59         }
60
61         $authority .= ':'.$this->port;
62
63         return $authority;
64     }
65
66     public function getUserInfo()
67     {
68         return $this->userInfo;
69     }
70
71     public function getHost()
72     {
73         return $this->host;
74     }
75
76     public function getPort()
77     {
78         return $this->port;
79     }
80
81     public function getPath()
82     {
83         return $this->path;
84     }
85
86     public function getQuery()
87     {
88         return $this->query;
89     }
90
91     public function getFragment()
92     {
93         return $this->fragment;
94     }
95
96     public function withScheme($scheme)
97     {
98         throw new \BadMethodCallException('Not implemented.');
99     }
100
101     public function withUserInfo($user, $password = null)
102     {
103         throw new \BadMethodCallException('Not implemented.');
104     }
105
106     public function withHost($host)
107     {
108         throw new \BadMethodCallException('Not implemented.');
109     }
110
111     public function withPort($port)
112     {
113         throw new \BadMethodCallException('Not implemented.');
114     }
115
116     public function withPath($path)
117     {
118         throw new \BadMethodCallException('Not implemented.');
119     }
120
121     public function withQuery($query)
122     {
123         throw new \BadMethodCallException('Not implemented.');
124     }
125
126     public function withFragment($fragment)
127     {
128         throw new \BadMethodCallException('Not implemented.');
129     }
130
131     public function __toString()
132     {
133         return $this->uriString;
134     }
135 }