diff --git a/src/Factories/DeviceFactory.php b/src/Factories/DeviceFactory.php index 871ea57..e3158f0 100644 --- a/src/Factories/DeviceFactory.php +++ b/src/Factories/DeviceFactory.php @@ -40,7 +40,7 @@ public function make(array $data): Device profile: (new ProfileFactory())->make($data['profile']), profile2: ! empty($data['profile2']) ? (new ProfileFactory())->make($data['profile2']) : null, description: $data['description'] ?? '', - stats: DeviceAnalytics::tryFrom($data['stats'] ?? null), + stats: ! empty($data['stats']) ? DeviceAnalytics::tryFrom($data['stats']) : DeviceAnalytics::OFF, icon: $data['icon'] ?? null, dynamicDns: $dynamicDns ?? null, dynamicDnsExternal: $externalDns ?? null, diff --git a/src/Resources/Devices.php b/src/Resources/Devices.php index dca53d4..81c8ac4 100644 --- a/src/Resources/Devices.php +++ b/src/Resources/Devices.php @@ -37,17 +37,17 @@ public function create( string $name, string $profilePk, string $icon, - string $profilePk2 = null, - int $stats = null, + ?string $profilePk2 = null, + ?int $stats = null, bool $legacyIpv4Status = false, bool $learnIp = false, bool $restricted = false, bool $bumpTls = false, - string $description = null, - int $ddnsStatus = null, - string $ddnsSubdomain = null, - int $ddnsExternalStatus = null, - string $ddnsExternalHost = null, + ?string $description = null, + ?int $ddnsStatus = null, + ?string $ddnsSubdomain = null, + ?int $ddnsExternalStatus = null, + ?string $ddnsExternalHost = null, ): Device { $response = $this->client->post('devices', [ 'name' => $name, @@ -91,22 +91,22 @@ public function analyticsLevels(): array public function modify( string $devicePk, - string $name = null, - string $profilePk = null, - string $icon = null, - string $profilePk2 = null, - int $stats = null, - bool $legacyIpv4Status = null, - bool $learnIp = null, - bool $restricted = null, - bool $bumpTls = null, - string $description = null, - int $ddnsStatus = null, - string $ddnsSubdomain = null, - int $ddnsExternalStatus = null, - string $ddnsExternalHost = null, - DeviceStatus $status = null, - string $ctrldCustomConfig = null, + ?string $name = null, + ?string $profilePk = null, + ?string $icon = null, + ?string $profilePk2 = null, + ?int $stats = null, + ?bool $legacyIpv4Status = null, + ?bool $learnIp = null, + ?bool $restricted = null, + ?bool $bumpTls = null, + ?string $description = null, + ?int $ddnsStatus = null, + ?string $ddnsSubdomain = null, + ?int $ddnsExternalStatus = null, + ?string $ddnsExternalHost = null, + ?DeviceStatus $status = null, + ?string $ctrldCustomConfig = null, ): Device { $response = $this->client->put("devices/{$devicePk}", [ 'name' => $name, diff --git a/src/Resources/MobileConfig.php b/src/Resources/MobileConfig.php index e192163..527cb2e 100644 --- a/src/Resources/MobileConfig.php +++ b/src/Resources/MobileConfig.php @@ -18,7 +18,7 @@ public function generateProfile( array $excludeDomain = [], bool $dontSign = false, bool $excludeCommon = false, - string $clientId = null, + ?string $clientId = null, ): string { return $this->client->get("mobileconfig/{$devicePk}", [ 'exclude_wifi' => $excludeWifi, diff --git a/src/Resources/Organizations.php b/src/Resources/Organizations.php index f34e03c..f806a8b 100644 --- a/src/Resources/Organizations.php +++ b/src/Resources/Organizations.php @@ -61,11 +61,11 @@ public function createSubOrganization( string $statsEndpoint, int $maxUsers, int $maxRouters, - string $address = null, - string $website = null, - string $contactName = null, - string $contactPhone = null, - string $parentProfile = null, + ?string $address = null, + ?string $website = null, + ?string $contactName = null, + ?string $contactPhone = null, + ?string $parentProfile = null, ): Organization { $response = $this->client->post('organizations/suborg', [ 'name' => $name, @@ -85,17 +85,17 @@ public function createSubOrganization( } public function modifyOrganization( - string $name = null, - string $contactEmail = null, - bool $twoFactorAuthenticationRequired = null, - string $statsEndpoint = null, - int $maxUsers = null, - int $maxRouters = null, - string $address = null, - string $website = null, - string $contactName = null, - string $contactPhone = null, - string $parentProfile = null, + ?string $name = null, + ?string $contactEmail = null, + ?bool $twoFactorAuthenticationRequired = null, + ?string $statsEndpoint = null, + ?int $maxUsers = null, + ?int $maxRouters = null, + ?string $address = null, + ?string $website = null, + ?string $contactName = null, + ?string $contactPhone = null, + ?string $parentProfile = null, ): Organization { $response = $this->client->put('organizations', [ 'name' => $name, diff --git a/src/Resources/Profiles.php b/src/Resources/Profiles.php index 150548f..1326aa8 100644 --- a/src/Resources/Profiles.php +++ b/src/Resources/Profiles.php @@ -38,7 +38,7 @@ public function list(): ProfileList return $result; } - public function create(string $name, string $cloneProfileId = null): Profile + public function create(string $name, ?string $cloneProfileId = null): Profile { $profile = $this->client->post('profiles', [ 'name' => $name, @@ -48,7 +48,7 @@ public function create(string $name, string $cloneProfileId = null): Profile return $this->profile->make($profile); } - public function modify(string $profilePk, string $name = null, int $disableTtl = null): Profile + public function modify(string $profilePk, ?string $name = null, ?int $disableTtl = null): Profile { $profile = $this->client->post("profiles/{$profilePk}", [ 'name' => $name, diff --git a/src/Resources/Profiles/CustomRules.php b/src/Resources/Profiles/CustomRules.php index 23be5d2..314ec1b 100644 --- a/src/Resources/Profiles/CustomRules.php +++ b/src/Resources/Profiles/CustomRules.php @@ -14,7 +14,7 @@ public function __construct(private readonly PendingRequest $client, private rea { } - public function list(string $profilePk, int $folderPk = null): \Rapkis\Controld\Responses\CustomRules + public function list(string $profilePk, ?int $folderPk = null): \Rapkis\Controld\Responses\CustomRules { $folderPk = $folderPk ?? 'all'; // This is the default folder in ControlD that lists all rules $response = $this->client->get("profiles/{$profilePk}/rules/{$folderPk}")->json('body.rules');