| Conditions | 4 |
| Paths | 5 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | protected function checkToken($token) |
||
| 19 | { |
||
| 20 | try { |
||
| 21 | $response = $this->http->get($this->checkTokenURL(), [ |
||
|
|
|||
| 22 | 'headers' => [ |
||
| 23 | 'X-Requested-With' => 'XMLHttpRequest', |
||
| 24 | 'Authorization' => 'Bearer ' . $token |
||
| 25 | ] |
||
| 26 | ]); |
||
| 27 | $content = json_decode($response->getBody()->getContents()); |
||
| 28 | if (isset($content->message)) { |
||
| 29 | if ($content->message === 'Token is valid') { |
||
| 30 | return true; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | } catch (\Exception $e) { |
||
| 34 | return false; |
||
| 35 | } |
||
| 36 | return false; |
||
| 37 | } |
||
| 38 | |||
| 47 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: