| Total Complexity | 4 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | class LanguagesClient extends NStackClient |
||
| 15 | { |
||
| 16 | /** @var string */ |
||
| 17 | protected $path = 'geographic/languages'; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * index |
||
| 21 | * |
||
| 22 | * @param int $page |
||
| 23 | * @param int $limit |
||
| 24 | * @return array |
||
| 25 | * @throws FailedToParseException |
||
| 26 | */ |
||
| 27 | 1 | public function index($page = 1, $limit = 500): array |
|
| 28 | { |
||
| 29 | 1 | $response = $this->client->get( |
|
| 30 | 1 | $this->buildPath($this->path) |
|
| 31 | 1 | . '/?page=' . $page |
|
| 32 | 1 | . '&limit=' . $limit |
|
| 33 | ); |
||
| 34 | |||
| 35 | 1 | $contents = $response->getBody()->getContents(); |
|
| 36 | |||
| 37 | 1 | $data = json_decode($contents, true); |
|
| 38 | |||
| 39 | 1 | $array = []; |
|
| 40 | 1 | foreach ($data['data'] as $object) { |
|
| 41 | 1 | $array[] = new Language($object); |
|
| 42 | } |
||
| 43 | |||
| 44 | 1 | return $array; |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * search |
||
| 49 | * |
||
| 50 | * @param String $term |
||
| 51 | * @param int $page |
||
| 52 | * @param int $limit |
||
| 53 | * @return array |
||
| 54 | * @throws FailedToParseException |
||
| 55 | */ |
||
| 56 | 1 | public function search(String $term, $page = 1, $limit = 500): array |
|
| 75 | } |
||
| 76 | } |