Conditions | 3 |
Paths | 5 |
Total Lines | 26 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 5.0538 |
Changes | 0 |
1 | <?php |
||
37 | 1 | private function request(string $url, string $method = 'GET', array $params = []): array |
|
38 | { |
||
39 | 1 | $url = self::ApiUrl . $url; |
|
40 | |||
41 | try { |
||
42 | 1 | $response = $this->client->request($method, $url, $params); |
|
43 | 1 | $response = json_decode($response->getBody()->getContents(), true); |
|
44 | 1 | getenv('APP_ENV') === 'dev' && $this->logger->debug('Guzzle request:', [ |
|
45 | 'url' => $url, |
||
46 | 'method' => $method, |
||
47 | 'params' => $params, |
||
48 | 1 | 'response' => $response, |
|
49 | ]); |
||
50 | } catch (GuzzleException $exception) { |
||
51 | $this->logger->error('Guzzle request failed.', [ |
||
52 | 'url' => $url, |
||
53 | 'method' => $method, |
||
54 | 'params' => $params, |
||
55 | 'exceptionMessage' => $exception->getMessage(), |
||
56 | 'exceptionCode' => $exception->getCode(), |
||
57 | ]); |
||
58 | $response = []; |
||
59 | } |
||
60 | |||
61 | 1 | return $response; |
|
62 | } |
||
63 | } |