Skip to content

Commit

Permalink
PSR12 format
Browse files Browse the repository at this point in the history
  • Loading branch information
abnegate committed Jan 10, 2024
1 parent 15cca19 commit 9824c91
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
8 changes: 4 additions & 4 deletions src/Utopia/Messaging/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Utopia/Messaging/Adapter/Chat/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
8 changes: 4 additions & 4 deletions src/Utopia/Messaging/Adapter/Email/Mailgun.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ 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']}>";
}
}
}

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']}>";
Expand Down
2 changes: 1 addition & 1 deletion src/Utopia/Messaging/Adapter/Email/Mock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Utopia/Messaging/Adapter/Email/Sendgrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
Expand Down
16 changes: 8 additions & 8 deletions src/Utopia/Messaging/Adapter/Push/FCM.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Utopia/Messaging/Helpers/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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');
}

Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/Utopia/Messaging/Messages/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand Down

0 comments on commit 9824c91

Please sign in to comment.