| Conditions | 2 |
| Paths | 2 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 8 | ||
| Bugs | 8 | Features | 2 |
| 1 | <?php |
||
| 46 | 2 | public function getRepos() |
|
| 47 | { |
||
| 48 | 2 | $url = "https://api.github.com/users/{$this->username}/repos"; |
|
| 49 | 2 | $client = new Client(); |
|
| 50 | 1 | ||
| 51 | //will return http response with the body in json format |
||
| 52 | 1 | $res = $client->request('GET', $url, ['exceptions' => false]); |
|
| 53 | 1 | if ($res->getStatusCode() == 404) { |
|
| 54 | 1 | throw new InvalidUsername("The username you passed is not a valid Github username", 1); |
|
| 55 | } |
||
| 56 | |||
| 57 | $decoded = json_decode($res->getBody(), true); |
||
| 58 | |||
| 59 | return count($decoded); |
||
| 60 | } |
||
| 61 | |||
| 62 | } |