Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

namespace Minishlink\WebPush;

/**
* @phpstan-consistent-constructor
* @psalm-consistent-constructor
*/
class Subscription implements SubscriptionInterface
{
public const defaultContentEncoding = ContentEncoding::aesgcm; // Default for legacy input. The next major will use "aes128gcm" as defined to rfc8291.
Expand Down Expand Up @@ -47,10 +51,10 @@ public function __construct(
* @param array $associativeArray (with keys endpoint, publicKey, authToken, contentEncoding)
* @throws \ErrorException
*/
public static function create(array $associativeArray): self
public static function create(array $associativeArray): static
{
if (array_key_exists('keys', $associativeArray) && is_array($associativeArray['keys'])) {
return new self(
return new static(
$associativeArray['endpoint'],
$associativeArray['keys']['p256dh'] ?? null,
$associativeArray['keys']['auth'] ?? null,
Expand All @@ -59,15 +63,15 @@ public static function create(array $associativeArray): self
}

if (array_key_exists('publicKey', $associativeArray) || array_key_exists('authToken', $associativeArray) || array_key_exists('contentEncoding', $associativeArray)) {
return new self(
return new static(
$associativeArray['endpoint'],
$associativeArray['publicKey'] ?? null,
$associativeArray['authToken'] ?? null,
$associativeArray['contentEncoding'] ?? ContentEncoding::aesgcm,
);
}

return new self(
return new static(
$associativeArray['endpoint']
);
}
Expand Down