@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | $this->apiKey = $apiKey; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function get(string $uri, array $params = []): array |
|
| 35 | + public function get(string $uri, array $params = [ ]): array |
|
| 36 | 36 | { |
| 37 | 37 | $response = $this->http->get( |
| 38 | 38 | $this->endpoint($uri, $params), |
| 39 | - ['X-Api-Key' => $this->apiKey] |
|
| 39 | + [ 'X-Api-Key' => $this->apiKey ] |
|
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | 42 | if (200 !== $response->getStatusCode()) { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | json_encode($data) |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - if (!in_array($response->getStatusCode(), [200, 201], true)) { |
|
| 78 | + if (!in_array($response->getStatusCode(), [ 200, 201 ], true)) { |
|
| 79 | 79 | throw $this->createExceptionFromResponse($response); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | json_encode($data) |
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | - if (!in_array($response->getStatusCode(), [200, 204], true)) { |
|
| 96 | + if (!in_array($response->getStatusCode(), [ 200, 204 ], true)) { |
|
| 97 | 97 | throw $this->createExceptionFromResponse($response); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - private function endpoint(string $uri, array $params = []): string |
|
| 114 | + private function endpoint(string $uri, array $params = [ ]): string |
|
| 115 | 115 | { |
| 116 | 116 | $endpoint = sprintf( |
| 117 | 117 | '%s/%s', |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | private function createExceptionFromResponse(ResponseInterface $response): ClockifyException |
| 130 | 130 | { |
| 131 | 131 | $data = json_decode((string) $response->getBody(), true); |
| 132 | - $message = $data['message'] ?? ''; |
|
| 133 | - $code = $data['code'] ?? 0; |
|
| 132 | + $message = $data[ 'message' ] ?? ''; |
|
| 133 | + $code = $data[ 'code' ] ?? 0; |
|
| 134 | 134 | |
| 135 | 135 | switch ($response->getStatusCode()) { |
| 136 | 136 | case 400: |
@@ -23,24 +23,24 @@ |
||
| 23 | 23 | public static function fromArray(array $data): self |
| 24 | 24 | { |
| 25 | 25 | return new self( |
| 26 | - $data['archived'], |
|
| 27 | - $data['billable'], |
|
| 28 | - $data['clientId'], |
|
| 29 | - $data['clientName'], |
|
| 30 | - $data['color'], |
|
| 31 | - $data['duration'], |
|
| 32 | - EstimateDto::fromArray($data['estimate']), |
|
| 33 | - $data['hourlyRate'] ? HourlyRateDto::fromArray($data['hourlyRate']) : null, |
|
| 34 | - $data['id'], |
|
| 26 | + $data[ 'archived' ], |
|
| 27 | + $data[ 'billable' ], |
|
| 28 | + $data[ 'clientId' ], |
|
| 29 | + $data[ 'clientName' ], |
|
| 30 | + $data[ 'color' ], |
|
| 31 | + $data[ 'duration' ], |
|
| 32 | + EstimateDto::fromArray($data[ 'estimate' ]), |
|
| 33 | + $data[ 'hourlyRate' ] ? HourlyRateDto::fromArray($data[ 'hourlyRate' ]) : null, |
|
| 34 | + $data[ 'id' ], |
|
| 35 | 35 | array_map( |
| 36 | 36 | static function(array $membership): MembershipDto { |
| 37 | 37 | return MembershipDto::fromArray($membership); |
| 38 | 38 | }, |
| 39 | - $data['memberships'] |
|
| 39 | + $data[ 'memberships' ] |
|
| 40 | 40 | ), |
| 41 | - $data['name'], |
|
| 42 | - $data['public'], |
|
| 43 | - $data['workspaceId'] |
|
| 41 | + $data[ 'name' ], |
|
| 42 | + $data[ 'public' ], |
|
| 43 | + $data[ 'workspaceId' ] |
|
| 44 | 44 | ); |
| 45 | 45 | } |
| 46 | 46 | |