| Total Complexity | 6 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | final class Request |
||
| 6 | { |
||
| 7 | private $error; |
||
| 8 | |||
| 9 | public function getRequestHeader(string $headerParam) |
||
| 10 | { |
||
| 11 | $headers = getallheaders(); |
||
| 12 | |||
| 13 | if ($headerParam == 'all') { |
||
| 14 | return $headers; |
||
| 15 | } |
||
| 16 | |||
| 17 | return isset($headers[$headerParam]) ? [$headerParam => $headers[$headerParam]] : false; |
||
| 18 | } |
||
| 19 | |||
| 20 | public function getToken() |
||
| 21 | { |
||
| 22 | if (!($token = $this->getRequestHeader('authorization'))) { |
||
| 23 | $this->error = "require login"; |
||
| 24 | return false; |
||
| 25 | } |
||
| 26 | |||
| 27 | $token = str_replace(['Bearer', ' '], '', $token['authorization']); |
||
| 28 | |||
| 29 | return $token; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function getError() |
||
| 35 | } |
||
| 36 | } |
||
| 37 |