@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $this->http = $http; |
24 | 24 | } |
25 | 25 | |
26 | - public function get(string $uri, array $params = []): array |
|
26 | + public function get(string $uri, array $params = [ ]): array |
|
27 | 27 | { |
28 | 28 | if (!empty($params)) { |
29 | 29 | $uri .= '?'.http_build_query($params); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public function post(string $uri, array $data): array |
42 | 42 | { |
43 | - $response = $this->http->post($uri, [], json_encode($data, JSON_THROW_ON_ERROR)); |
|
43 | + $response = $this->http->post($uri, [ ], json_encode($data, JSON_THROW_ON_ERROR)); |
|
44 | 44 | |
45 | 45 | if (201 !== $response->getStatusCode()) { |
46 | 46 | throw $this->createExceptionFromResponse($response); |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | |
52 | 52 | public function put(string $uri, array $data): array |
53 | 53 | { |
54 | - $response = $this->http->put($uri, [], json_encode($data, JSON_THROW_ON_ERROR)); |
|
54 | + $response = $this->http->put($uri, [ ], json_encode($data, JSON_THROW_ON_ERROR)); |
|
55 | 55 | |
56 | - if (!in_array($response->getStatusCode(), [200, 201], true)) { |
|
56 | + if (!in_array($response->getStatusCode(), [ 200, 201 ], true)) { |
|
57 | 57 | throw $this->createExceptionFromResponse($response); |
58 | 58 | } |
59 | 59 | |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | |
63 | 63 | public function patch(string $uri, array $data): array |
64 | 64 | { |
65 | - $response = $this->http->patch($uri, [], json_encode($data, JSON_THROW_ON_ERROR)); |
|
65 | + $response = $this->http->patch($uri, [ ], json_encode($data, JSON_THROW_ON_ERROR)); |
|
66 | 66 | |
67 | - if (!in_array($response->getStatusCode(), [200, 204], true)) { |
|
67 | + if (!in_array($response->getStatusCode(), [ 200, 204 ], true)) { |
|
68 | 68 | throw $this->createExceptionFromResponse($response); |
69 | 69 | } |
70 | 70 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | private function createExceptionFromResponse(ResponseInterface $response): ClockifyException |
84 | 84 | { |
85 | 85 | $data = json_decode((string) $response->getBody(), true); |
86 | - $message = $data['message'] ?? ''; |
|
87 | - $code = $data['code'] ?? 0; |
|
86 | + $message = $data[ 'message' ] ?? ''; |
|
87 | + $code = $data[ 'code' ] ?? 0; |
|
88 | 88 | |
89 | 89 | switch ($response->getStatusCode()) { |
90 | 90 | case 400: |
@@ -19,20 +19,20 @@ |
||
19 | 19 | public static function fromArray(array $data): self |
20 | 20 | { |
21 | 21 | return new self( |
22 | - $data['activeWorkspace'] ? $data['activeWorkspace'] : '', |
|
23 | - $data['defaultWorkspace'] ? $data['defaultWorkspace'] : '', |
|
24 | - $data['email'], |
|
25 | - $data['id'], |
|
22 | + $data[ 'activeWorkspace' ] ? $data[ 'activeWorkspace' ] : '', |
|
23 | + $data[ 'defaultWorkspace' ] ? $data[ 'defaultWorkspace' ] : '', |
|
24 | + $data[ 'email' ], |
|
25 | + $data[ 'id' ], |
|
26 | 26 | array_map( |
27 | 27 | static function(array $membership): MembershipDto { |
28 | 28 | return MembershipDto::fromArray($membership); |
29 | 29 | }, |
30 | - $data['memberships'] |
|
30 | + $data[ 'memberships' ] |
|
31 | 31 | ), |
32 | - $data['name'] ? $data['name'] : '', |
|
33 | - $data['profilePicture'] ? $data['profilePicture'] : '', |
|
34 | - $data['settings'] ? UserSettingsDto::fromArray($data['settings']) : null, |
|
35 | - new UserStatus($data['status']) |
|
32 | + $data[ 'name' ] ? $data[ 'name' ] : '', |
|
33 | + $data[ 'profilePicture' ] ? $data[ 'profilePicture' ] : '', |
|
34 | + $data[ 'settings' ] ? UserSettingsDto::fromArray($data[ 'settings' ]) : null, |
|
35 | + new UserStatus($data[ 'status' ]) |
|
36 | 36 | ); |
37 | 37 | } |
38 | 38 |
@@ -15,9 +15,9 @@ |
||
15 | 15 | public static function fromArray(array $data): self |
16 | 16 | { |
17 | 17 | return new self( |
18 | - new DateTimeImmutable($data['start']), |
|
19 | - $data['end'] ? new DateTimeImmutable($data['end']) : null, |
|
20 | - $data['duration'] ? $data['duration'] : '' |
|
18 | + new DateTimeImmutable($data[ 'start' ]), |
|
19 | + $data[ 'end' ] ? new DateTimeImmutable($data[ 'end' ]) : null, |
|
20 | + $data[ 'duration' ] ? $data[ 'duration' ] : '' |
|
21 | 21 | ); |
22 | 22 | } |
23 | 23 |
@@ -20,16 +20,16 @@ |
||
20 | 20 | public static function fromArray(array $data): self |
21 | 21 | { |
22 | 22 | return new self( |
23 | - $data['billable'], |
|
24 | - $data['description'], |
|
25 | - $data['id'], |
|
26 | - $data['isLocked'], |
|
27 | - $data['projectId'] ? $data['projectId'] : '', |
|
28 | - $data['tagIds'] ? $data['tagIds'] : [], |
|
29 | - $data['taskId'] ? $data['taskId'] : '', |
|
30 | - TimeIntervalDto::fromArray($data['timeInterval']), |
|
31 | - $data['userId'], |
|
32 | - $data['workspaceId'] |
|
23 | + $data[ 'billable' ], |
|
24 | + $data[ 'description' ], |
|
25 | + $data[ 'id' ], |
|
26 | + $data[ 'isLocked' ], |
|
27 | + $data[ 'projectId' ] ? $data[ 'projectId' ] : '', |
|
28 | + $data[ 'tagIds' ] ? $data[ 'tagIds' ] : [ ], |
|
29 | + $data[ 'taskId' ] ? $data[ 'taskId' ] : '', |
|
30 | + TimeIntervalDto::fromArray($data[ 'timeInterval' ]), |
|
31 | + $data[ 'userId' ], |
|
32 | + $data[ 'workspaceId' ] |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 |