Lint PHP code psr-12, add GH action

This commit is contained in:
Julien Nahum
2024-02-23 11:54:12 +01:00
parent e85e4df7fe
commit 62971a2ef4
226 changed files with 2338 additions and 2144 deletions

View File

@@ -6,7 +6,6 @@ use App\Models\Forms\Form;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Str;
use Spatie\WebhookServer\Events\WebhookCallFailedEvent;
class FailedWebhookNotification extends Notification
@@ -14,6 +13,7 @@ class FailedWebhookNotification extends Notification
use Queueable;
public Form $form;
public string $provider;
/**
@@ -30,7 +30,7 @@ class FailedWebhookNotification extends Notification
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
@@ -41,13 +41,13 @@ class FailedWebhookNotification extends Notification
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject("Notification issue with your NotionForm: '" . $this->form->title . "'")
return (new MailMessage())
->subject("Notification issue with your NotionForm: '".$this->form->title."'")
->markdown('mail.form.webhook-error', [
'provider' => $this->provider,
'error' => $this->event->errorMessage,

View File

@@ -8,8 +8,8 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Str;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
class FormSubmissionNotification extends Notification implements ShouldQueue
{
@@ -52,7 +52,7 @@ class FormSubmissionNotification extends Notification implements ShouldQueue
->outputStringsOnly()
->useSignedUrlForFiles();
return (new MailMessage)
return (new MailMessage())
->replyTo($this->getReplyToEmail($notifiable->routes['mail']))
->from($this->getFromEmail(), config('app.name'))
->subject('New form submission for "'.$this->event->form->title.'"')
@@ -65,15 +65,17 @@ class FormSubmissionNotification extends Notification implements ShouldQueue
private function getFromEmail()
{
$originalFromAddress = Str::of(config('mail.from.address'))->explode('@');
return $originalFromAddress->first(). '+' . time() . '@' . $originalFromAddress->last();
return $originalFromAddress->first().'+'.time().'@'.$originalFromAddress->last();
}
private function getReplyToEmail($default)
{
$replyTo = Arr::get((array)$this->event->form->notification_settings, 'notification_reply_to', null);
$replyTo = Arr::get((array) $this->event->form->notification_settings, 'notification_reply_to', null);
if ($replyTo && $this->validateEmail($replyTo)) {
return $replyTo;
}
return $this->getRespondentEmail() ?? $default;
}
@@ -83,7 +85,7 @@ class FormSubmissionNotification extends Notification implements ShouldQueue
$emailFields = collect($this->event->form->properties)->filter(function ($field) {
$hidden = $field['hidden'] ?? false;
return !$hidden && $field['type'] == 'email';
return ! $hidden && $field['type'] == 'email';
});
if ($emailFields->count() != 1) {
return null;
@@ -101,7 +103,6 @@ class FormSubmissionNotification extends Notification implements ShouldQueue
public static function validateEmail($email): bool
{
return (bool)filter_var($email, FILTER_VALIDATE_EMAIL);
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
}
}