| Conditions | 4 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public static function get(String $route) |
||
| 25 | { |
||
| 26 | try { |
||
| 27 | return json_decode(Provider::$http->request( |
||
| 28 | 'GET', |
||
| 29 | "api/$route", |
||
| 30 | [ |
||
| 31 | 'headers' => [ |
||
| 32 | 'X-Requested-With' => 'XMLHttpRequest', |
||
| 33 | 'Authorization' => 'Bearer ' . Provider::makeJWT() |
||
|
|
|||
| 34 | ] |
||
| 35 | ]) |
||
| 36 | ->getBody() |
||
| 37 | ->getContents() |
||
| 38 | ); |
||
| 39 | } catch (GuzzleException $e) { |
||
| 40 | if ($e->getCode() == 401) { |
||
| 41 | try { |
||
| 42 | Provider::generateJwt(); |
||
| 43 | } catch (GuzzleException $e) { |
||
| 44 | die($e->getMessage()); |
||
| 45 | } |
||
| 46 | self::get($route); |
||
| 47 | } |
||
| 48 | return null; |
||
| 49 | } |
||
| 69 | } |