diff --git a/src/Utopia/Messaging/Adapter/Chat/Discord.php b/src/Utopia/Messaging/Adapter/Chat/Discord.php index bc84ff1..b17ecc5 100644 --- a/src/Utopia/Messaging/Adapter/Chat/Discord.php +++ b/src/Utopia/Messaging/Adapter/Chat/Discord.php @@ -8,9 +8,9 @@ class Discord extends Adapter { - private const NAME = 'Discord'; - private const TYPE = 'chat'; - private const MESSAGE_TYPE = DiscordMessage::class; + protected const NAME = 'Discord'; + protected const TYPE = 'chat'; + protected const MESSAGE_TYPE = DiscordMessage::class; /** * @param string $webhookId Your Discord webhook ID. @@ -24,17 +24,17 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getType(): string { - return self::TYPE; + return static::TYPE; } public function getMessageType(): string { - return self::MESSAGE_TYPE; + return static::MESSAGE_TYPE; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/Email.php b/src/Utopia/Messaging/Adapter/Email.php index 0bbafba..267e88c 100644 --- a/src/Utopia/Messaging/Adapter/Email.php +++ b/src/Utopia/Messaging/Adapter/Email.php @@ -7,17 +7,17 @@ abstract class Email extends Adapter { - private const TYPE = 'email'; - private const MESSAGE_TYPE = EmailMessage::class; + protected const TYPE = 'email'; + protected const MESSAGE_TYPE = EmailMessage::class; public function getType(): string { - return self::TYPE; + return static::TYPE; } public function getMessageType(): string { - return self::MESSAGE_TYPE; + return static::MESSAGE_TYPE; } /** diff --git a/src/Utopia/Messaging/Adapter/Email/Mailgun.php b/src/Utopia/Messaging/Adapter/Email/Mailgun.php index 253f84f..48c85ae 100644 --- a/src/Utopia/Messaging/Adapter/Email/Mailgun.php +++ b/src/Utopia/Messaging/Adapter/Email/Mailgun.php @@ -8,7 +8,7 @@ class Mailgun extends EmailAdapter { - private const NAME = 'Mailgun'; + protected const NAME = 'Mailgun'; /** * @param string $apiKey Your Mailgun API key to authenticate with the API. @@ -26,7 +26,7 @@ public function __construct( */ public function getName(): string { - return self::NAME; + return static::NAME; } /** diff --git a/src/Utopia/Messaging/Adapter/Email/Mock.php b/src/Utopia/Messaging/Adapter/Email/Mock.php index 0a1454e..8caa9f3 100644 --- a/src/Utopia/Messaging/Adapter/Email/Mock.php +++ b/src/Utopia/Messaging/Adapter/Email/Mock.php @@ -9,11 +9,11 @@ class Mock extends EmailAdapter { - private const NAME = 'Mock'; + protected const NAME = 'Mock'; public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/Email/Sendgrid.php b/src/Utopia/Messaging/Adapter/Email/Sendgrid.php index c9d0b75..8c22594 100644 --- a/src/Utopia/Messaging/Adapter/Email/Sendgrid.php +++ b/src/Utopia/Messaging/Adapter/Email/Sendgrid.php @@ -8,7 +8,7 @@ class Sendgrid extends EmailAdapter { - private const NAME = 'Sendgrid'; + protected const NAME = 'Sendgrid'; /** * @param string $apiKey Your Sendgrid API key to authenticate with the API. @@ -23,7 +23,7 @@ public function __construct(private string $apiKey) */ public function getName(): string { - return self::NAME; + return static::NAME; } /** diff --git a/src/Utopia/Messaging/Adapter/Push.php b/src/Utopia/Messaging/Adapter/Push.php index e1ee92c..54c8571 100644 --- a/src/Utopia/Messaging/Adapter/Push.php +++ b/src/Utopia/Messaging/Adapter/Push.php @@ -7,23 +7,23 @@ abstract class Push extends Adapter { - private const TYPE = 'push'; - private const MESSAGE_TYPE = PushMessage::class; - private const EXPIRED_MESSAGE = 'Expired device token.'; + protected const TYPE = 'push'; + protected const MESSAGE_TYPE = PushMessage::class; + protected const EXPIRED_MESSAGE = 'Expired device token.'; public function getType(): string { - return self::TYPE; + return static::TYPE; } public function getMessageType(): string { - return self::MESSAGE_TYPE; + return static::MESSAGE_TYPE; } protected function getExpiredErrorMessage(): string { - return self::EXPIRED_MESSAGE; + return static::EXPIRED_MESSAGE; } /** diff --git a/src/Utopia/Messaging/Adapter/Push/APNS.php b/src/Utopia/Messaging/Adapter/Push/APNS.php index a2b0000..dd12bba 100644 --- a/src/Utopia/Messaging/Adapter/Push/APNS.php +++ b/src/Utopia/Messaging/Adapter/Push/APNS.php @@ -9,7 +9,7 @@ class APNS extends PushAdapter { - private const NAME = 'APNS'; + protected const NAME = 'APNS'; /** * @return void @@ -28,7 +28,7 @@ public function __construct( */ public function getName(): string { - return self::NAME; + return static::NAME; } /** diff --git a/src/Utopia/Messaging/Adapter/Push/FCM.php b/src/Utopia/Messaging/Adapter/Push/FCM.php index b976b0e..aa5fbb9 100644 --- a/src/Utopia/Messaging/Adapter/Push/FCM.php +++ b/src/Utopia/Messaging/Adapter/Push/FCM.php @@ -9,10 +9,10 @@ class FCM extends PushAdapter { - private const NAME = 'FCM'; - private const DEFAULT_EXPIRY_SECONDS = 3600; // 1 hour - private const DEFAULT_SKEW_SECONDS = 60; // 1 minute - private const GOOGLE_TOKEN_URL = 'https://www.googleapis.com/oauth2/v4/token'; + protected const NAME = 'FCM'; + protected const DEFAULT_EXPIRY_SECONDS = 3600; // 1 hour + protected const DEFAULT_SKEW_SECONDS = 60; // 1 minute + protected const GOOGLE_TOKEN_URL = 'https://www.googleapis.com/oauth2/v4/token'; /** * @param string $serviceAccountJSON Service account JSON file contents @@ -27,7 +27,7 @@ public function __construct( */ public function getName(): string { - return self::NAME; + return static::NAME; } /** diff --git a/src/Utopia/Messaging/Adapter/SMS.php b/src/Utopia/Messaging/Adapter/SMS.php index aa681e9..4dbcb87 100644 --- a/src/Utopia/Messaging/Adapter/SMS.php +++ b/src/Utopia/Messaging/Adapter/SMS.php @@ -7,17 +7,17 @@ abstract class SMS extends Adapter { - private const TYPE = 'sms'; - private const MESSAGE_TYPE = SMSMessage::class; + protected const TYPE = 'sms'; + protected const MESSAGE_TYPE = SMSMessage::class; public function getType(): string { - return self::TYPE; + return static::TYPE; } public function getMessageType(): string { - return self::MESSAGE_TYPE; + return static::MESSAGE_TYPE; } /** diff --git a/src/Utopia/Messaging/Adapter/SMS/Clickatell.php b/src/Utopia/Messaging/Adapter/SMS/Clickatell.php index 9cd47bd..915ca62 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Clickatell.php +++ b/src/Utopia/Messaging/Adapter/SMS/Clickatell.php @@ -10,7 +10,7 @@ // https://docs.clickatell.com/channels/sms-channels/sms-api-reference/#tag/SMS-API/operation/sendMessageREST_1 class Clickatell extends SMSAdapter { - private const NAME = 'Clickatell'; + protected const NAME = 'Clickatell'; /** * @param string $apiKey Clickatell API Key @@ -23,7 +23,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/GEOSMS.php b/src/Utopia/Messaging/Adapter/SMS/GEOSMS.php index a15297d..b1955ca 100644 --- a/src/Utopia/Messaging/Adapter/SMS/GEOSMS.php +++ b/src/Utopia/Messaging/Adapter/SMS/GEOSMS.php @@ -8,7 +8,7 @@ class GEOSMS extends SMSAdapter { - private const NAME = 'GEOSMS'; + protected const NAME = 'GEOSMS'; protected SMSAdapter $defaultAdapter; @@ -24,7 +24,7 @@ public function __construct(SMSAdapter $defaultAdapter) public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/Infobip.php b/src/Utopia/Messaging/Adapter/SMS/Infobip.php index 378ea7a..1ea53b5 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Infobip.php +++ b/src/Utopia/Messaging/Adapter/SMS/Infobip.php @@ -10,7 +10,7 @@ // https://www.infobip.com/docs/api/channels/sms/sms-messaging/outbound-sms/send-sms-message class Infobip extends SMSAdapter { - private const NAME = 'Infobip'; + protected const NAME = 'Infobip'; /** * @param string $apiBaseUrl Infobip API Base Url @@ -25,7 +25,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/Mock.php b/src/Utopia/Messaging/Adapter/SMS/Mock.php index dea6ae4..0079d8d 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Mock.php +++ b/src/Utopia/Messaging/Adapter/SMS/Mock.php @@ -8,6 +8,8 @@ class Mock extends SMSAdapter { + protected const NAME = 'Mock'; + /** * @param string $user User ID * @param string $secret User secret @@ -18,6 +20,11 @@ public function __construct( ) { } + public function getName(): string + { + return static::NAME; + } + public function getMaxMessagesPerRequest(): int { return 1000; diff --git a/src/Utopia/Messaging/Adapter/SMS/Msg91.php b/src/Utopia/Messaging/Adapter/SMS/Msg91.php index 4307865..c0d52f1 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Msg91.php +++ b/src/Utopia/Messaging/Adapter/SMS/Msg91.php @@ -11,7 +11,7 @@ class Msg91 extends SMSAdapter { - private const NAME = 'Msg91'; + protected const NAME = 'Msg91'; /** * @param string $senderId Msg91 Sender ID @@ -27,7 +27,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/Plivo.php b/src/Utopia/Messaging/Adapter/SMS/Plivo.php index a287e12..061fa11 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Plivo.php +++ b/src/Utopia/Messaging/Adapter/SMS/Plivo.php @@ -10,7 +10,7 @@ // https://www.plivo.com/docs/sms/api/message#send-a-message class Plivo extends SMSAdapter { - private const NAME = 'Plivo'; + protected const NAME = 'Plivo'; /** * @param string $authId Plivo Auth ID @@ -25,7 +25,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/Seven.php b/src/Utopia/Messaging/Adapter/SMS/Seven.php index 7a01333..681313e 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Seven.php +++ b/src/Utopia/Messaging/Adapter/SMS/Seven.php @@ -10,7 +10,7 @@ // https://www.seven.io/en/docs/gateway/http-api/sms-dispatch/ class Seven extends SMSAdapter { - private const NAME = 'Seven'; + protected const NAME = 'Seven'; /** * @param string $apiKey Seven API token @@ -23,7 +23,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/Sinch.php b/src/Utopia/Messaging/Adapter/SMS/Sinch.php index d37e367..0cbaaa5 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Sinch.php +++ b/src/Utopia/Messaging/Adapter/SMS/Sinch.php @@ -10,7 +10,7 @@ // https://developers.sinch.com/docs/sms/api-reference/ class Sinch extends SMSAdapter { - private const NAME = 'Sinch'; + protected const NAME = 'Sinch'; /** * @param string $servicePlanId Sinch Service plan ID @@ -25,7 +25,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/Telesign.php b/src/Utopia/Messaging/Adapter/SMS/Telesign.php index 41871dc..e9c1674 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Telesign.php +++ b/src/Utopia/Messaging/Adapter/SMS/Telesign.php @@ -11,7 +11,7 @@ class Telesign extends SMSAdapter { - private const NAME = 'Telesign'; + protected const NAME = 'Telesign'; /** * @param string $username Telesign account username @@ -25,7 +25,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/Telnyx.php b/src/Utopia/Messaging/Adapter/SMS/Telnyx.php index d79aff4..118be67 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Telnyx.php +++ b/src/Utopia/Messaging/Adapter/SMS/Telnyx.php @@ -8,7 +8,7 @@ class Telnyx extends SMSAdapter { - private const NAME = 'Telnyx'; + protected const NAME = 'Telnyx'; /** * @param string $apiKey Telnyx APIv2 Key @@ -21,7 +21,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/TextMagic.php b/src/Utopia/Messaging/Adapter/SMS/TextMagic.php index 8abfa7a..81da593 100644 --- a/src/Utopia/Messaging/Adapter/SMS/TextMagic.php +++ b/src/Utopia/Messaging/Adapter/SMS/TextMagic.php @@ -11,7 +11,7 @@ class TextMagic extends SMSAdapter { - private const NAME = 'Textmagic'; + protected const NAME = 'Textmagic'; /** * @param string $username Textmagic account username @@ -26,7 +26,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/Twilio.php b/src/Utopia/Messaging/Adapter/SMS/Twilio.php index b72a1c4..8e15e8c 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Twilio.php +++ b/src/Utopia/Messaging/Adapter/SMS/Twilio.php @@ -8,7 +8,7 @@ class Twilio extends SMSAdapter { - private const NAME = 'Twilio'; + protected const NAME = 'Twilio'; /** * @param string $accountSid Twilio Account SID @@ -23,7 +23,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Adapter/SMS/Vonage.php b/src/Utopia/Messaging/Adapter/SMS/Vonage.php index 47fbf72..c950e17 100644 --- a/src/Utopia/Messaging/Adapter/SMS/Vonage.php +++ b/src/Utopia/Messaging/Adapter/SMS/Vonage.php @@ -11,7 +11,7 @@ class Vonage extends SMSAdapter { - private const NAME = 'Vonage'; + protected const NAME = 'Vonage'; /** * @param string $apiKey Vonage API Key @@ -26,7 +26,7 @@ public function __construct( public function getName(): string { - return self::NAME; + return static::NAME; } public function getMaxMessagesPerRequest(): int diff --git a/src/Utopia/Messaging/Helpers/JWT.php b/src/Utopia/Messaging/Helpers/JWT.php index fe92407..ba4f4b8 100644 --- a/src/Utopia/Messaging/Helpers/JWT.php +++ b/src/Utopia/Messaging/Helpers/JWT.php @@ -4,7 +4,7 @@ class JWT { - private const ALGORITHMS = [ + protected const ALGORITHMS = [ 'ES384' => ['openssl', OPENSSL_ALGO_SHA384], 'ES256' => ['openssl', OPENSSL_ALGO_SHA256], 'ES256K' => ['openssl', OPENSSL_ALGO_SHA256], @@ -55,11 +55,11 @@ public static function encode(array $payload, string $key, string $algorithm, st */ private static function sign(string $data, string $key, string $alg): string { - if (empty(self::ALGORITHMS[$alg])) { + if (empty(static::ALGORITHMS[$alg])) { throw new \Exception('Algorithm not supported'); } - [$function, $algorithm] = self::ALGORITHMS[$alg]; + [$function, $algorithm] = static::ALGORITHMS[$alg]; switch ($function) { case 'openssl':