1 | <?php |
||
15 | class OAuthServerException extends \Exception |
||
16 | { |
||
17 | /** |
||
18 | * @var int |
||
19 | */ |
||
20 | private $httpStatusCode; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $errorType; |
||
26 | |||
27 | /** |
||
28 | * @var null|string |
||
29 | */ |
||
30 | private $hint; |
||
31 | |||
32 | /** |
||
33 | * @var null|string |
||
34 | */ |
||
35 | private $redirectUri; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | private $payload; |
||
41 | |||
42 | /** |
||
43 | * @var ServerRequest |
||
44 | */ |
||
45 | private $serverRequest; |
||
|
|||
46 | |||
47 | /** |
||
48 | * Throw a new exception. |
||
49 | * |
||
50 | * @param string $message Error message |
||
51 | * @param int $code Error code |
||
52 | * @param string $errorType Error type |
||
53 | * @param int $httpStatusCode HTTP status code to send (default = 400) |
||
54 | * @param null|string $hint A helper hint |
||
55 | * @param null|string $redirectUri A HTTP URI to redirect the user back to |
||
56 | */ |
||
57 | 67 | public function __construct($message, $code, $errorType, $httpStatusCode = 400, $hint = null, $redirectUri = null) |
|
72 | |||
73 | /** |
||
74 | * Returns the current payload. |
||
75 | * |
||
76 | * @return array |
||
77 | */ |
||
78 | 7 | public function getPayload() |
|
82 | |||
83 | /** |
||
84 | * Updates the current payload. |
||
85 | * |
||
86 | * @param array $payload |
||
87 | */ |
||
88 | public function setPayload(array $payload) |
||
92 | |||
93 | /** |
||
94 | * Set the server request that is responsible for generating the exception |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | 15 | public function setServerRequest($serverRequest) |
|
102 | |||
103 | /** |
||
104 | * Unsupported grant type error. |
||
105 | * |
||
106 | * @return static |
||
107 | */ |
||
108 | 2 | public static function unsupportedGrantType() |
|
115 | |||
116 | /** |
||
117 | * Invalid request error. |
||
118 | * |
||
119 | * @param string $parameter The invalid parameter |
||
120 | * @param null|string $hint |
||
121 | * |
||
122 | * @return static |
||
123 | */ |
||
124 | 22 | public static function invalidRequest($parameter, $hint = null) |
|
132 | |||
133 | /** |
||
134 | * Invalid client error. |
||
135 | * |
||
136 | * @param ServerRequest $serverRequest |
||
137 | * |
||
138 | * @return static |
||
139 | */ |
||
140 | 15 | public static function invalidClient($serverRequest) |
|
150 | |||
151 | /** |
||
152 | * Invalid scope error. |
||
153 | * |
||
154 | * @param string $scope The bad scope |
||
155 | * @param null|string $redirectUri A HTTP URI to redirect the user back to |
||
156 | * |
||
157 | * @return static |
||
158 | */ |
||
159 | 4 | public static function invalidScope($scope, $redirectUri = null) |
|
174 | |||
175 | /** |
||
176 | * Invalid credentials error. |
||
177 | * |
||
178 | * @return static |
||
179 | */ |
||
180 | 1 | public static function invalidCredentials() |
|
184 | |||
185 | /** |
||
186 | * Server error. |
||
187 | * |
||
188 | * @param string $hint |
||
189 | * |
||
190 | * @return static |
||
191 | * |
||
192 | * @codeCoverageIgnore |
||
193 | */ |
||
194 | public static function serverError($hint) |
||
204 | |||
205 | /** |
||
206 | * Invalid refresh token. |
||
207 | * |
||
208 | * @param null|string $hint |
||
209 | * |
||
210 | * @return static |
||
211 | */ |
||
212 | 4 | public static function invalidRefreshToken($hint = null) |
|
216 | |||
217 | /** |
||
218 | * Access denied. |
||
219 | * |
||
220 | * @param null|string $hint |
||
221 | * @param null|string $redirectUri |
||
222 | * |
||
223 | * @return static |
||
224 | */ |
||
225 | 9 | public static function accessDenied($hint = null, $redirectUri = null) |
|
236 | |||
237 | /** |
||
238 | * Invalid grant. |
||
239 | * |
||
240 | * @param string $hint |
||
241 | * |
||
242 | * @return static |
||
243 | */ |
||
244 | 1 | public static function invalidGrant($hint = '') |
|
256 | |||
257 | /** |
||
258 | * @return string |
||
259 | */ |
||
260 | 2 | public function getErrorType() |
|
264 | |||
265 | /** |
||
266 | * Generate a HTTP response. |
||
267 | * |
||
268 | * @param ResponseInterface $response |
||
269 | * @param bool $useFragment True if errors should be in the URI fragment instead of query string |
||
270 | * @param int $jsonOptions options passed to json_encode |
||
271 | * |
||
272 | * @return ResponseInterface |
||
273 | */ |
||
274 | 7 | public function generateHttpResponse(ResponseInterface $response, $useFragment = false, $jsonOptions = 0) |
|
298 | |||
299 | /** |
||
300 | * Get all headers that have to be send with the error response. |
||
301 | * |
||
302 | * @return array Array with header values |
||
303 | */ |
||
304 | 7 | public function getHttpHeaders() |
|
327 | |||
328 | /** |
||
329 | * Returns the HTTP status code to send when the exceptions is output. |
||
330 | * |
||
331 | * @return int |
||
332 | */ |
||
333 | 7 | public function getHttpStatusCode() |
|
337 | |||
338 | /** |
||
339 | * @return null|string |
||
340 | */ |
||
341 | 14 | public function getHint() |
|
345 | } |
||
346 |
This check marks private properties in classes that are never used. Those properties can be removed.