| Total Complexity | 11 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class Client |
||
| 12 | { |
||
| 13 | private $http; |
||
| 14 | |||
| 15 | public function __construct(Http $http) |
||
| 16 | { |
||
| 17 | $this->http = $http; |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @return ClientDto[] |
||
| 22 | */ |
||
| 23 | public function clients(string $workspaceId, array $params = []): array |
||
| 24 | { |
||
| 25 | if (isset($params['name']) && empty($params['name'])) { |
||
| 26 | throw new ClockifyException('Invalid "name" parameter'); |
||
| 27 | } |
||
| 28 | |||
| 29 | if (isset($params['page']) && (!is_int($params['page']) || $params['page'] < 1)) { |
||
| 30 | throw new ClockifyException('Invalid "page" parameter'); |
||
| 31 | } |
||
| 32 | |||
| 33 | if (isset($params['page-size']) && (!is_int($params['page-size']) || $params['page-size'] < 1)) { |
||
| 34 | throw new ClockifyException('Invalid "page-size" parameter'); |
||
| 35 | } |
||
| 36 | |||
| 37 | $data = $this->http->get("/workspaces/$workspaceId/clients", $params); |
||
| 38 | |||
| 39 | return array_map( |
||
| 40 | static function(array $client): ClientDto { |
||
| 41 | return ClientDto::fromArray($client); |
||
| 42 | }, |
||
| 43 | $data |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function createClient(string $workspaceId, ClientRequest $request): ClientDto |
||
| 52 | } |
||
| 53 | } |
||
| 54 |