From 9a436a8f68f544f8d75be1dc51fa83ddfa942ebe Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Wed, 11 Oct 2023 14:39:53 +0200 Subject: [PATCH] Apply code improvements by Rector --- lib/ApiClient/Http/Client.php | 2 +- lib/ApiClient/Http/Response.php | 6 +++--- lib/ApiClient/TicketparkApiClient.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ApiClient/Http/Client.php b/lib/ApiClient/Http/Client.php index bcaccc5..fcfef2f 100644 --- a/lib/ApiClient/Http/Client.php +++ b/lib/ApiClient/Http/Client.php @@ -13,7 +13,7 @@ final class Client implements ClientInterface { - private GuzzleClient $guzzle; + private readonly GuzzleClient $guzzle; public function __construct() { diff --git a/lib/ApiClient/Http/Response.php b/lib/ApiClient/Http/Response.php index 77e1802..b76d49e 100644 --- a/lib/ApiClient/Http/Response.php +++ b/lib/ApiClient/Http/Response.php @@ -22,7 +22,7 @@ public function getStatusCode(): int public function getContent(): array { - return json_decode($this->content, true); + return json_decode($this->content, true, 512, JSON_THROW_ON_ERROR); } public function getHeaders(): array @@ -80,8 +80,8 @@ private function getLastElementOfLocationHeader(): ?string private function getLocationHeaderContent(): ?string { foreach($this->getHeaders() as $header) { - if (str_starts_with(strtolower($header), 'location:')) { - return trim(preg_replace('/^.+?:/', '', $header)); + if (str_starts_with(strtolower((string) $header), 'location:')) { + return trim(preg_replace('/^.+?:/', '', (string) $header)); } } diff --git a/lib/ApiClient/TicketparkApiClient.php b/lib/ApiClient/TicketparkApiClient.php index 93bcf3b..c05e48f 100644 --- a/lib/ApiClient/TicketparkApiClient.php +++ b/lib/ApiClient/TicketparkApiClient.php @@ -12,7 +12,7 @@ class TicketparkApiClient { - public const ROOT_URL = 'https://api.ticketpark.ch'; + final public const ROOT_URL = 'https://api.ticketpark.ch'; private const REFRESH_TOKEN_LIFETIME = 30 * 86400; private ?ClientInterface $client = null;