1 | <?php |
||
9 | class UriConfig implements UriConfigInterface |
||
10 | { |
||
11 | /** |
||
12 | * The UriParserInterface implementation. |
||
13 | * |
||
14 | * @return \Risan\OAuth1\Request\UriParserInterface |
||
15 | */ |
||
16 | protected $parser; |
||
17 | |||
18 | /** |
||
19 | * The base URI. |
||
20 | * |
||
21 | * @var \Psr\Http\Message\UriInterface|null |
||
22 | */ |
||
23 | protected $base; |
||
24 | |||
25 | /** |
||
26 | * The URI for obtaining temporary credentials. Also known as request token |
||
27 | * URI. |
||
28 | * |
||
29 | * @var \Psr\Http\Message\UriInterface |
||
30 | */ |
||
31 | protected $temporaryCredentials; |
||
32 | |||
33 | /** |
||
34 | * The URI for asking user to authorize the request. |
||
35 | * |
||
36 | * @var \Psr\Http\Message\UriInterface |
||
37 | */ |
||
38 | protected $authorization; |
||
39 | |||
40 | /** |
||
41 | * The URI for obtaining token credentials. Also known as access token |
||
42 | * URI. |
||
43 | * |
||
44 | * @var \Psr\Http\Message\UriInterface |
||
45 | */ |
||
46 | protected $tokenCredentials; |
||
47 | |||
48 | /** |
||
49 | * The callback URI. |
||
50 | * |
||
51 | * @var \Psr\Http\Message\UriInterface|null |
||
52 | */ |
||
53 | protected $callback; |
||
54 | |||
55 | /** |
||
56 | * Create UriConfig instance. |
||
57 | * |
||
58 | * @param array $uris |
||
59 | * @param \Risan\OAuth1\Request\UriParserInterface $parser |
||
60 | */ |
||
61 | public function __construct(array $uris, UriParserInterface $parser) |
||
66 | |||
67 | /** |
||
68 | * {@inheritDoc} |
||
69 | */ |
||
70 | public function getParser() |
||
74 | |||
75 | /** |
||
76 | * Set URIs from an array. |
||
77 | * |
||
78 | * @param array $uris |
||
79 | * @return \Risan\OAuth1\Config\UriConfig |
||
80 | */ |
||
81 | public function setFromArray(array $uris) |
||
99 | |||
100 | /** |
||
101 | * Validate the given URI array. |
||
102 | * |
||
103 | * @param array $uris |
||
104 | * @return boolean |
||
105 | * @throws \InvalidArgumentException |
||
106 | */ |
||
107 | public function validateUris(array $uris) |
||
123 | |||
124 | /** |
||
125 | * Set the base URI. |
||
126 | * |
||
127 | * @param \Psr\Http\Message\UriInterface $uri |
||
128 | * @return \Risan\OAuth1\Config\UriConfig |
||
129 | * @throws \InvalidArgumentException |
||
130 | */ |
||
131 | public function setBase(UriInterface $uri) |
||
141 | |||
142 | /** |
||
143 | * {@inheritDoc} |
||
144 | */ |
||
145 | public function base() |
||
149 | |||
150 | /** |
||
151 | * {@inheritDoc} |
||
152 | */ |
||
153 | public function hasBase() |
||
157 | |||
158 | /** |
||
159 | * {@inheritDoc} |
||
160 | */ |
||
161 | public function forTemporaryCredentials() |
||
165 | |||
166 | /** |
||
167 | * {@inheritDoc} |
||
168 | */ |
||
169 | public function forAuthorization() |
||
173 | |||
174 | /** |
||
175 | * {@inheritDoc} |
||
176 | */ |
||
177 | public function forTokenCredentials() |
||
181 | |||
182 | /** |
||
183 | * {@inheritDoc} |
||
184 | */ |
||
185 | public function callback() |
||
189 | |||
190 | /** |
||
191 | * {@inheritDoc} |
||
192 | */ |
||
193 | public function hasCallback() |
||
197 | |||
198 | /** |
||
199 | * Parse and build the given URI. |
||
200 | * |
||
201 | * @param \Psr\Http\Message\UriInterface|string $uri |
||
202 | * @return \Psr\Http\Message\UriInterface |
||
203 | */ |
||
204 | public function build($uri) |
||
214 | |||
215 | /** |
||
216 | * Check if the given URI should be resolved to absolute URI. |
||
217 | * |
||
218 | * @param \Psr\Http\Message\UriInterface $uri |
||
219 | * @return boolean |
||
220 | */ |
||
221 | public function shouldBeResolvedToAbsoluteUri(UriInterface $uri) |
||
225 | } |
||
226 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: