From a5e3b4898423daa3867373215818e4cdca19cb95 Mon Sep 17 00:00:00 2001 From: carapidev Date: Sat, 30 Nov 2024 13:56:35 -0500 Subject: [PATCH 1/4] Check for content encoding --- src/CarApi.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/CarApi.php b/src/CarApi.php index e3a153e..dee28b8 100644 --- a/src/CarApi.php +++ b/src/CarApi.php @@ -85,7 +85,12 @@ public function authenticate(): string ); } - if (in_array('gzip', $this->config->encoding) && \extension_loaded('zlib')) { + $encoding = array_map(fn (string $str) => strtolower($str), $response->getHeader('Content-Encoding')); + if ( + in_array('gzip', $encoding) && + in_array('gzip', $this->config->encoding) && + \extension_loaded('zlib') + ) { $body = gzdecode($body); if ($body === false) { throw new CarApiException('Unable to decompress response. Maybe try without gzip.'); @@ -242,8 +247,7 @@ public function licensePlate(string $countryCode, string $lookup, ?string $regio 'lookup' => $lookup, 'region' => $region, ] - ] - ); + ]); } /** @@ -432,7 +436,12 @@ private function getDecoded(string $url, array $options = [], ?bool $associative $response = $this->get($url, $options); $body = (string) $response->getBody(); - if (in_array('gzip', $this->config->encoding) && \extension_loaded('zlib')) { + $encoding = array_map(fn (string $str) => strtolower($str), $response->getHeader('Content-Encoding')); + if ( + in_array('gzip', $encoding) && + in_array('gzip', $this->config->encoding) && + \extension_loaded('zlib') + ) { $body = gzdecode($body); if ($body === false) { throw new CarApiException('Unable to decompress response. Maybe try without gzip.'); From 13501c744331ff2abfa6c34afb7bffbccbe7ddf7 Mon Sep 17 00:00:00 2001 From: carapidev Date: Sat, 30 Nov 2024 13:58:33 -0500 Subject: [PATCH 2/4] lint fix --- src/CarApi.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/CarApi.php b/src/CarApi.php index dee28b8..a72fc22 100644 --- a/src/CarApi.php +++ b/src/CarApi.php @@ -86,10 +86,9 @@ public function authenticate(): string } $encoding = array_map(fn (string $str) => strtolower($str), $response->getHeader('Content-Encoding')); - if ( - in_array('gzip', $encoding) && - in_array('gzip', $this->config->encoding) && - \extension_loaded('zlib') + if (in_array('gzip', $encoding) + && in_array('gzip', $this->config->encoding) + && \extension_loaded('zlib') ) { $body = gzdecode($body); if ($body === false) { @@ -247,7 +246,8 @@ public function licensePlate(string $countryCode, string $lookup, ?string $regio 'lookup' => $lookup, 'region' => $region, ] - ]); + ] + ); } /** @@ -437,10 +437,9 @@ private function getDecoded(string $url, array $options = [], ?bool $associative $body = (string) $response->getBody(); $encoding = array_map(fn (string $str) => strtolower($str), $response->getHeader('Content-Encoding')); - if ( - in_array('gzip', $encoding) && - in_array('gzip', $this->config->encoding) && - \extension_loaded('zlib') + if (in_array('gzip', $encoding) + && in_array('gzip', $this->config->encoding) + && \extension_loaded('zlib') ) { $body = gzdecode($body); if ($body === false) { From c128d966d3a8933e5aedd80defa07abf9fba72a6 Mon Sep 17 00:00:00 2001 From: carapidev Date: Sat, 30 Nov 2024 13:58:52 -0500 Subject: [PATCH 3/4] add php 8.4 to actions --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7060b6b..befe91e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: operating-system: [ ubuntu-22.04 ] - php-versions: ['7.4', '8.3'] + php-versions: ['7.4', '8.4'] steps: - name: Checkout uses: actions/checkout@v2 From 23240fcb5dc4b664b201c2c3cc4b45e26256680c Mon Sep 17 00:00:00 2001 From: carapidev Date: Sat, 30 Nov 2024 14:00:22 -0500 Subject: [PATCH 4/4] remove php 8.4 from actions (for now) --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index befe91e..7060b6b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: operating-system: [ ubuntu-22.04 ] - php-versions: ['7.4', '8.4'] + php-versions: ['7.4', '8.3'] steps: - name: Checkout uses: actions/checkout@v2