@@ -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: |