| Conditions | 5 |
| Paths | 5 |
| Total Lines | 29 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | public static function get(String $route) |
||
| 28 | { |
||
| 29 | try { |
||
| 30 | return json_decode(Provider::$http->request( |
||
| 31 | 'GET', |
||
| 32 | 'api/' . $route, |
||
| 33 | [ |
||
| 34 | 'headers' => [ |
||
| 35 | 'X-Requested-With' => 'XMLHttpRequest', |
||
| 36 | 'Authorization' => 'Bearer ' . Provider::makeJWT() |
||
|
|
|||
| 37 | ] |
||
| 38 | ]) |
||
| 39 | ->getBody() |
||
| 40 | ->getContents() |
||
| 41 | ); |
||
| 42 | } catch (GuzzleException $e) { |
||
| 43 | if ($e->getCode() == 401) { |
||
| 44 | try { |
||
| 45 | Provider::generateJwt(); |
||
| 46 | } catch (GuzzleException $e) { |
||
| 47 | die($e->getMessage()); |
||
| 48 | } |
||
| 49 | self::get($route); |
||
| 50 | } else if ($e->getCode() == 404) { |
||
| 51 | return null; |
||
| 52 | } else { |
||
| 53 | throw new \Exception($e); |
||
| 54 | } |
||
| 55 | return null; |
||
| 56 | } |
||
| 80 | } |