From 9824c9111116ac451418d7123127d403e14b9df5 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 11 Jan 2024 12:45:59 +1300 Subject: [PATCH] PSR12 format --- src/Utopia/Messaging/Adapter.php | 8 ++++---- src/Utopia/Messaging/Adapter/Chat/Discord.php | 4 ++-- src/Utopia/Messaging/Adapter/Email/Mailgun.php | 8 ++++---- src/Utopia/Messaging/Adapter/Email/Mock.php | 2 +- src/Utopia/Messaging/Adapter/Email/Sendgrid.php | 8 ++++---- src/Utopia/Messaging/Adapter/Push/FCM.php | 16 ++++++++-------- src/Utopia/Messaging/Helpers/JWT.php | 6 +++--- src/Utopia/Messaging/Messages/Email.php | 8 ++++---- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index ee302832..54197556 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -41,13 +41,13 @@ abstract public function getMaxMessagesPerRequest(): int; */ public function send(Message $message): array { - if (! \is_a($message, $this->getMessageType())) { + if (!\is_a($message, $this->getMessageType())) { throw new \Exception('Invalid message type.'); } if (\method_exists($message, 'getTo') && \count($message->getTo()) > $this->getMaxMessagesPerRequest()) { throw new \Exception("{$this->getName()} can only send {$this->getMaxMessagesPerRequest()} messages per request."); } - if (! \method_exists($this, 'process')) { + if (!\method_exists($this, 'process')) { throw new \Exception('Adapter does not implement process method.'); } @@ -80,7 +80,7 @@ protected function request( ): array { $ch = \curl_init(); - if (! \is_null($body)) { + if (!\is_null($body)) { $headers[] = 'Content-Length: '.\strlen($body); \curl_setopt($ch, CURLOPT_POSTFIELDS, $body); } @@ -173,7 +173,7 @@ protected function requestMulti( } foreach (\array_combine($urls, $bodies) as $url => $body) { - if (! empty($body)) { + if (!empty($body)) { $headers[] = 'Content-Length: '.\strlen($body); } diff --git a/src/Utopia/Messaging/Adapter/Chat/Discord.php b/src/Utopia/Messaging/Adapter/Chat/Discord.php index 61ea3f44..bc84ff1c 100644 --- a/src/Utopia/Messaging/Adapter/Chat/Discord.php +++ b/src/Utopia/Messaging/Adapter/Chat/Discord.php @@ -51,10 +51,10 @@ protected function process(DiscordMessage $message): array { $query = []; - if (! \is_null($message->getWait())) { + if (!\is_null($message->getWait())) { $query['wait'] = $message->getWait(); } - if (! \is_null($message->getThreadId())) { + if (!\is_null($message->getThreadId())) { $query['thread_id'] = $message->getThreadId(); } diff --git a/src/Utopia/Messaging/Adapter/Email/Mailgun.php b/src/Utopia/Messaging/Adapter/Email/Mailgun.php index dac80e91..253f84f5 100644 --- a/src/Utopia/Messaging/Adapter/Email/Mailgun.php +++ b/src/Utopia/Messaging/Adapter/Email/Mailgun.php @@ -55,9 +55,9 @@ protected function process(EmailMessage $message): array 'html' => $message->isHtml() ? $message->getContent() : null, ]; - if (! \is_null($message->getCC())) { + if (!\is_null($message->getCC())) { foreach ($message->getCC() as $cc) { - if (! empty($cc['name'])) { + if (!empty($cc['name'])) { $body['cc'] = "{$body['cc']},{$cc['name']}<{$cc['email']}>"; } else { $body['cc'] = "{$body['cc']}, <{$cc['email']}>"; @@ -65,9 +65,9 @@ protected function process(EmailMessage $message): array } } - if (! \is_null($message->getBCC())) { + if (!\is_null($message->getBCC())) { foreach ($message->getBCC() as $bcc) { - if (! empty($bcc['name'])) { + if (!empty($bcc['name'])) { $body['bcc'] = "{$body['bcc']},{$bcc['name']}<{$bcc['email']}>"; } else { $body['bcc'] = "{$body['bcc']}, <{$bcc['email']}>"; diff --git a/src/Utopia/Messaging/Adapter/Email/Mock.php b/src/Utopia/Messaging/Adapter/Email/Mock.php index fbb8d419..0a1454ee 100644 --- a/src/Utopia/Messaging/Adapter/Email/Mock.php +++ b/src/Utopia/Messaging/Adapter/Email/Mock.php @@ -50,7 +50,7 @@ protected function process(EmailMessage $message): array $mail->addAddress($to); } - if (! $mail->send()) { + if (!$mail->send()) { foreach ($message->getTo() as $to) { $response->addResultForRecipient($to, $mail->ErrorInfo); } diff --git a/src/Utopia/Messaging/Adapter/Email/Sendgrid.php b/src/Utopia/Messaging/Adapter/Email/Sendgrid.php index 815eccdf..c9d0b753 100644 --- a/src/Utopia/Messaging/Adapter/Email/Sendgrid.php +++ b/src/Utopia/Messaging/Adapter/Email/Sendgrid.php @@ -49,9 +49,9 @@ protected function process(EmailMessage $message): array ], ]; - if (! \is_null($message->getCC())) { + if (!\is_null($message->getCC())) { foreach ($message->getCC() as $cc) { - if (! empty($cc['name'])) { + if (!empty($cc['name'])) { $personalizations[0]['cc'][] = [ 'name' => $cc['name'], 'email' => $cc['email'], @@ -64,9 +64,9 @@ protected function process(EmailMessage $message): array } } - if (! \is_null($message->getBCC())) { + if (!\is_null($message->getBCC())) { foreach ($message->getBCC() as $bcc) { - if (! empty($bcc['name'])) { + if (!empty($bcc['name'])) { $personalizations[0]['bcc'][] = [ 'name' => $bcc['name'], 'email' => $bcc['email'], diff --git a/src/Utopia/Messaging/Adapter/Push/FCM.php b/src/Utopia/Messaging/Adapter/Push/FCM.php index dd4d0d64..b976b0e7 100644 --- a/src/Utopia/Messaging/Adapter/Push/FCM.php +++ b/src/Utopia/Messaging/Adapter/Push/FCM.php @@ -90,32 +90,32 @@ protected function process(PushMessage $message): array ], ]; - if (! \is_null($message->getData())) { + if (!\is_null($message->getData())) { $shared['message']['data'] = $message->getData(); } - if (! \is_null($message->getAction())) { + if (!\is_null($message->getAction())) { $shared['message']['android']['notification']['click_action'] = $message->getAction(); $shared['message']['apns']['payload']['aps']['category'] = $message->getAction(); } - if (! \is_null($message->getImage())) { + if (!\is_null($message->getImage())) { $shared['message']['android']['notification']['image'] = $message->getImage(); $shared['message']['apns']['payload']['aps']['mutable-content'] = 1; $shared['message']['apns']['fcm_options']['image'] = $message->getImage(); } - if (! \is_null($message->getSound())) { + if (!\is_null($message->getSound())) { $shared['message']['android']['notification']['sound'] = $message->getSound(); $shared['message']['apns']['payload']['aps']['sound'] = $message->getSound(); } - if (! \is_null($message->getIcon())) { + if (!\is_null($message->getIcon())) { $shared['message']['android']['notification']['icon'] = $message->getIcon(); } - if (! \is_null($message->getColor())) { + if (!\is_null($message->getColor())) { $shared['message']['android']['notification']['color'] = $message->getColor(); } - if (! \is_null($message->getTag())) { + if (!\is_null($message->getTag())) { $shared['message']['android']['notification']['tag'] = $message->getTag(); } - if (! \is_null($message->getBadge())) { + if (!\is_null($message->getBadge())) { $shared['message']['apns']['payload']['aps']['badge'] = $message->getBadge(); } diff --git a/src/Utopia/Messaging/Helpers/JWT.php b/src/Utopia/Messaging/Helpers/JWT.php index 58ce506d..fe924075 100644 --- a/src/Utopia/Messaging/Helpers/JWT.php +++ b/src/Utopia/Messaging/Helpers/JWT.php @@ -30,7 +30,7 @@ public static function encode(array $payload, string $key, string $algorithm, st 'alg' => $algorithm, ]; - if (! \is_null($keyId)) { + if (!\is_null($keyId)) { $header['kid'] = $keyId; } @@ -67,7 +67,7 @@ private static function sign(string $data, string $key, string $alg): string $success = \openssl_sign($data, $signature, $key, $algorithm); - if (! $success) { + if (!$success) { throw new \Exception('OpenSSL sign failed for JWT'); } @@ -144,7 +144,7 @@ private static function readDER(string $der, int $offset = 0): array $pos++; // Skip the first contents octet (padding indicator) $data = \substr($der, $pos, $len - 1); $pos += $len - 1; - } elseif (! $constructed) { + } elseif (!$constructed) { $data = \substr($der, $pos, $len); $pos += $len; } else { diff --git a/src/Utopia/Messaging/Messages/Email.php b/src/Utopia/Messaging/Messages/Email.php index 268a4dde..2a02e939 100644 --- a/src/Utopia/Messaging/Messages/Email.php +++ b/src/Utopia/Messaging/Messages/Email.php @@ -42,17 +42,17 @@ public function __construct( $this->replyToEmail = $this->fromEmail; } - if (! \is_null($this->cc)) { + if (!\is_null($this->cc)) { foreach ($this->cc as $recipient) { - if (! isset($recipient['name']) || ! isset($recipient['email'])) { + if (!isset($recipient['name']) || !isset($recipient['email'])) { throw new \InvalidArgumentException('Each recipient in cc must have a name and email'); } } } - if (! \is_null($this->bcc)) { + if (!\is_null($this->bcc)) { foreach ($this->bcc as $recipient) { - if (! isset($recipient['name']) || ! isset($recipient['email'])) { + if (!isset($recipient['name']) || !isset($recipient['email'])) { throw new \InvalidArgumentException('Each recipient in bcc must have a name and email'); } }