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