From cb51ffd18dbd6ea6d6150622abfaeb54a32b0643 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 2 Sep 2024 13:18:14 +0200 Subject: [PATCH] Enhancement: Use `\sprintf` in `buildApiUrl` --- src/Client/AssignLicenseClient.php | 7 ++++++- src/Client/CancelRetryClient.php | 7 ++++++- src/Client/CheckLicenseClient.php | 8 +++++++- src/Client/GlancesClient.php | 7 ++++++- src/Client/MessageClient.php | 7 ++++++- src/Client/ReceiptClient.php | 8 +++++++- src/Client/SubscriptionClient.php | 7 ++++++- src/Client/UserGroupValidationClient.php | 7 ++++++- 8 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/Client/AssignLicenseClient.php b/src/Client/AssignLicenseClient.php index 40b6c1b..bc2a266 100644 --- a/src/Client/AssignLicenseClient.php +++ b/src/Client/AssignLicenseClient.php @@ -28,7 +28,12 @@ class AssignLicenseClient extends Client implements ClientInterface public function buildApiUrl(): string { - return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/'.self::API_PATH; + return sprintf( + '%s/%s/%s', + Curl::API_BASE_URL, + Curl::API_VERSION, + self::API_PATH, + ); } /** diff --git a/src/Client/CancelRetryClient.php b/src/Client/CancelRetryClient.php index 9c1bea3..96b49b7 100644 --- a/src/Client/CancelRetryClient.php +++ b/src/Client/CancelRetryClient.php @@ -33,7 +33,12 @@ public function __construct( public function buildApiUrl(): string { - return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/receipts/'.$this->receipt.'/cancel.json'; + return sprintf( + '%s/%s/receipts/%s/cancel.json', + Curl::API_BASE_URL, + Curl::API_VERSION, + $this->receipt, + ); } /** diff --git a/src/Client/CheckLicenseClient.php b/src/Client/CheckLicenseClient.php index 273acf4..6b3f32a 100644 --- a/src/Client/CheckLicenseClient.php +++ b/src/Client/CheckLicenseClient.php @@ -32,6 +32,12 @@ public function __construct( public function buildApiUrl(): string { - return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/'.self::API_PATH.'?token='.$this->license->getApplication()->getToken(); + return sprintf( + '%s/%s/%s?token=%s', + Curl::API_BASE_URL, + Curl::API_VERSION, + self::API_PATH, + $this->license->getApplication()->getToken(), + ); } } diff --git a/src/Client/GlancesClient.php b/src/Client/GlancesClient.php index 5ca1b3c..7ad8090 100644 --- a/src/Client/GlancesClient.php +++ b/src/Client/GlancesClient.php @@ -28,7 +28,12 @@ class GlancesClient extends Client implements ClientInterface public function buildApiUrl(): string { - return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/'.self::API_PATH; + return sprintf( + '%s/%s/%s', + Curl::API_BASE_URL, + Curl::API_VERSION, + self::API_PATH, + ); } /** diff --git a/src/Client/MessageClient.php b/src/Client/MessageClient.php index 4bb6d30..a381d5b 100644 --- a/src/Client/MessageClient.php +++ b/src/Client/MessageClient.php @@ -34,7 +34,12 @@ class MessageClient extends Client implements ClientInterface public function buildApiUrl(): string { - return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/'.self::API_PATH; + return sprintf( + '%s/%s/%s', + Curl::API_BASE_URL, + Curl::API_VERSION, + self::API_PATH, + ); } /** diff --git a/src/Client/ReceiptClient.php b/src/Client/ReceiptClient.php index 598a9ad..98abdb5 100644 --- a/src/Client/ReceiptClient.php +++ b/src/Client/ReceiptClient.php @@ -31,6 +31,12 @@ public function __construct( public function buildApiUrl(): string { - return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/receipts/'.$this->receipt.'.json?token='.$this->application->getToken(); + return sprintf( + '%s/%s/receipts/%s.json?token=%s', + Curl::API_BASE_URL, + Curl::API_VERSION, + $this->receipt, + $this->application->getToken(), + ); } } diff --git a/src/Client/SubscriptionClient.php b/src/Client/SubscriptionClient.php index b88acbb..5bcb5d6 100644 --- a/src/Client/SubscriptionClient.php +++ b/src/Client/SubscriptionClient.php @@ -30,7 +30,12 @@ class SubscriptionClient extends Client implements ClientInterface public function buildApiUrl(): string { - return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/'.self::API_PATH; + return sprintf( + '%s/%s/%s', + Curl::API_BASE_URL, + Curl::API_VERSION, + self::API_PATH, + ); } /** diff --git a/src/Client/UserGroupValidationClient.php b/src/Client/UserGroupValidationClient.php index c05c350..ebdc087 100644 --- a/src/Client/UserGroupValidationClient.php +++ b/src/Client/UserGroupValidationClient.php @@ -27,7 +27,12 @@ class UserGroupValidationClient extends Client implements ClientInterface public function buildApiUrl(): string { - return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/'.self::API_PATH; + return \sprintf( + '%s/%s/%s', + Curl::API_BASE_URL, + Curl::API_VERSION, + self::API_PATH, + ); } /**