diff --git a/src/Client/Response/CreateGroupResponse.php b/src/Client/Response/CreateGroupResponse.php index 32daa47..8312dd9 100644 --- a/src/Client/Response/CreateGroupResponse.php +++ b/src/Client/Response/CreateGroupResponse.php @@ -25,7 +25,7 @@ class CreateGroupResponse extends Response /** * Obtained group key. */ - private string $groupKey; + private ?string $groupKey = null; public function __construct(string $curlResponse) { @@ -33,9 +33,9 @@ public function __construct(string $curlResponse) } /** - * @return string Obtained group key + * @return null|string Obtained group key or null if the request failed */ - public function getGroupKey(): string + public function getGroupKey(): ?string { return $this->groupKey; } diff --git a/src/Client/Response/LicenseResponse.php b/src/Client/Response/LicenseResponse.php index f986d21..22db584 100644 --- a/src/Client/Response/LicenseResponse.php +++ b/src/Client/Response/LicenseResponse.php @@ -25,14 +25,17 @@ class LicenseResponse extends Response /** * Number of license credits remaining. */ - private int $credits; + private ?int $credits = null; public function __construct(string $curlResponse) { $this->processCurlResponse($curlResponse); } - public function getCredits(): int + /** + * @return null|int License credits or null if the request failed + */ + public function getCredits(): ?int { return $this->credits; } diff --git a/src/Client/Response/RetrieveGroupResponse.php b/src/Client/Response/RetrieveGroupResponse.php index 7166be2..eb83668 100644 --- a/src/Client/Response/RetrieveGroupResponse.php +++ b/src/Client/Response/RetrieveGroupResponse.php @@ -28,19 +28,22 @@ class RetrieveGroupResponse extends Response /** * Name of the group. */ - private string $name; + private ?string $name = null; /** * @var Recipient[] Group users */ - private array $users; + private array $users = []; public function __construct(string $curlResponse) { $this->processCurlResponse($curlResponse); } - public function getName(): string + /** + * @return null|string Group name or null if the request failed + */ + public function getName(): ?string { return $this->name; } diff --git a/src/Client/Response/SubscriptionResponse.php b/src/Client/Response/SubscriptionResponse.php index 976b057..5f23bfe 100644 --- a/src/Client/Response/SubscriptionResponse.php +++ b/src/Client/Response/SubscriptionResponse.php @@ -25,14 +25,17 @@ class SubscriptionResponse extends Response /** * Applications that formerly collected Pushover user keys are encouraged to migrate to subscription keys. */ - private string $subscribed_user_key; + private ?string $subscribed_user_key = null; public function __construct(string $curlResponse) { $this->processCurlResponse($curlResponse); } - public function getSubscribedUserKey(): string + /** + * @return null|string Subscribed user key or null if the request failed + */ + public function getSubscribedUserKey(): ?string { return $this->subscribed_user_key; } diff --git a/src/Client/Response/UserGroupValidationResponse.php b/src/Client/Response/UserGroupValidationResponse.php index c235461..f69ce38 100644 --- a/src/Client/Response/UserGroupValidationResponse.php +++ b/src/Client/Response/UserGroupValidationResponse.php @@ -22,17 +22,17 @@ */ class UserGroupValidationResponse extends Response { - private bool $isGroup; + private ?bool $isGroup = null; /** * @var array */ - private array $devices; + private array $devices = []; /** * @var array */ - private array $licenses; + private array $licenses = []; public function __construct(string $curlResponse) { @@ -60,41 +60,20 @@ public function getLicenses(): array return $this->licenses; } - private function setIsGroup(bool $isGroup): void - { - $this->isGroup = $isGroup; - } - - /** - * @param array $devices - */ - private function setDevices(array $devices): void - { - $this->devices = $devices; - } - - /** - * @param array $licenses - */ - private function setLicenses(array $licenses): void - { - $this->licenses = $licenses; - } - private function processCurlResponse(string $curlResponse): void { $decodedCurlResponse = $this->processInitialCurlResponse($curlResponse); if ($this->getRequestStatus() === 1) { - $this->setDevices($decodedCurlResponse->devices); - $this->setLicenses($decodedCurlResponse->licenses); + $this->devices = $decodedCurlResponse->devices; + $this->licenses = $decodedCurlResponse->licenses; if ($decodedCurlResponse->group === 1) { - $this->setIsGroup(true); + $this->isGroup = true; } if ($decodedCurlResponse->group === 0) { - $this->setIsGroup(false); + $this->isGroup = false; } } }