Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -45,8 +45,6 @@ class BillReminder extends Notification
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(Bill $bill, string $field, int $diff)
{
@@ -61,12 +59,12 @@ class BillReminder extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
return [
//
];
}
@@ -76,6 +74,7 @@ class BillReminder extends Notification
* @param mixed $notifiable
*
* @return MailMessage
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
@@ -87,7 +86,8 @@ class BillReminder extends Notification
return (new MailMessage())
->markdown('emails.bill-warning', ['field' => $this->field, 'diff' => $this->diff, 'bill' => $this->bill])
->subject($subject);
->subject($subject)
;
}
/**
@@ -96,6 +96,7 @@ class BillReminder extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
@@ -106,12 +107,14 @@ class BillReminder extends Notification
}
$bill = $this->bill;
$url = route('bills.show', [$bill->id]);
return (new SlackMessage())
->warning()
->attachment(static function ($attachment) use ($bill, $url) {
$attachment->title((string)trans('firefly.visit_bill', ['name' => $bill->name]), $url);
})
->content($message);
->content($message)
;
}
/**
@@ -120,11 +123,12 @@ class BillReminder extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{
/** @var User|null $user */
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
@@ -133,6 +137,7 @@ class BillReminder extends Notification
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -40,8 +40,6 @@ class NewAccessToken extends Notification
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct() {}
@@ -51,12 +49,12 @@ class NewAccessToken extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
return [
//
];
}
@@ -66,13 +64,15 @@ class NewAccessToken extends Notification
* @param mixed $notifiable
*
* @return MailMessage
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
return (new MailMessage())
->markdown('emails.token-created')
->subject((string)trans('email.access_token_created_subject'));
->subject((string)trans('email.access_token_created_subject'))
;
}
/**
@@ -81,6 +81,7 @@ class NewAccessToken extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
@@ -94,11 +95,12 @@ class NewAccessToken extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{
/** @var User|null $user */
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
@@ -107,6 +109,7 @@ class NewAccessToken extends Notification
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -45,8 +45,6 @@ class RuleActionFailed extends Notification
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(array $params)
{
@@ -56,8 +54,6 @@ class RuleActionFailed extends Notification
$this->groupLink = $groupLink;
$this->ruleTitle = $ruleTitle;
$this->ruleLink = $ruleLink;
}
/**
@@ -66,12 +62,12 @@ class RuleActionFailed extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
return [
//
];
}
@@ -81,6 +77,7 @@ class RuleActionFailed extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
@@ -103,11 +100,12 @@ class RuleActionFailed extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{
/** @var User|null $user */
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
@@ -115,9 +113,11 @@ class RuleActionFailed extends Notification
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
app('log')->debug('Will send ruleActionFailed through Slack!');
return ['slack'];
}
app('log')->debug('Will NOT send ruleActionFailed through Slack');
return [];
}
}

View File

@@ -39,8 +39,6 @@ class TransactionCreation extends Notification
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(array $collection)
{
@@ -53,12 +51,12 @@ class TransactionCreation extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
return [
//
];
}
@@ -68,13 +66,15 @@ class TransactionCreation extends Notification
* @param mixed $notifiable
*
* @return MailMessage
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
return (new MailMessage())
->markdown('emails.report-new-journals', ['transformed' => $this->collection])
->subject(trans_choice('email.new_journals_subject', count($this->collection)));
->subject(trans_choice('email.new_journals_subject', count($this->collection)))
;
}
/**
@@ -83,6 +83,7 @@ class TransactionCreation extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)

View File

@@ -43,8 +43,6 @@ class UserLogin extends Notification
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(string $ip)
{
@@ -57,12 +55,12 @@ class UserLogin extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
return [
//
];
}
@@ -72,12 +70,14 @@ class UserLogin extends Notification
* @param mixed $notifiable
*
* @return MailMessage
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
$time = now(config('app.timezone'))->isoFormat((string)trans('config.date_time_js'));
$host = '';
try {
$hostName = app('steam')->getHostName($this->ip);
} catch (FireflyException $e) {
@@ -90,7 +90,8 @@ class UserLogin extends Notification
return (new MailMessage())
->markdown('emails.new-ip', ['time' => $time, 'ipAddress' => $this->ip, 'host' => $host])
->subject((string)trans('email.login_from_new_ip'));
->subject((string)trans('email.login_from_new_ip'))
;
}
/**
@@ -99,11 +100,13 @@ class UserLogin extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
{
$host = '';
try {
$hostName = app('steam')->getHostName($this->ip);
} catch (FireflyException $e) {
@@ -123,11 +126,12 @@ class UserLogin extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{
/** @var User|null $user */
/** @var null|User $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (is_array($slackUrl)) {
@@ -136,6 +140,7 @@ class UserLogin extends Notification
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -39,8 +39,6 @@ class UserNewPassword extends Notification
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(string $url)
{
@@ -53,12 +51,12 @@ class UserNewPassword extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
return [
//
];
}
@@ -68,13 +66,15 @@ class UserNewPassword extends Notification
* @param mixed $notifiable
*
* @return MailMessage
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
return (new MailMessage())
->markdown('emails.password', ['url' => $this->url])
->subject((string)trans('email.reset_pw_subject'));
->subject((string)trans('email.reset_pw_subject'))
;
}
/**
@@ -83,6 +83,7 @@ class UserNewPassword extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)

View File

@@ -37,8 +37,6 @@ class UserRegistration extends Notification
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct() {}
@@ -48,12 +46,12 @@ class UserRegistration extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
return [
//
];
}
@@ -63,13 +61,15 @@ class UserRegistration extends Notification
* @param mixed $notifiable
*
* @return MailMessage
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
return (new MailMessage())
->markdown('emails.registered', ['address' => route('index')])
->subject((string)trans('email.registered_subject'));
->subject((string)trans('email.registered_subject'))
;
}
/**
@@ -78,6 +78,7 @@ class UserRegistration extends Notification
* @param mixed $notifiable
*
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)