Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze authored and github-actions[bot] committed Aug 7, 2024
1 parent 98b8b73 commit 5b67271
Show file tree
Hide file tree
Showing 53 changed files with 126 additions and 156 deletions.
2 changes: 1 addition & 1 deletion src/BackupDestination/BackupCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BackupCollection extends Collection
public static function createFromFiles(?FileSystem $disk, array $files): self
{
return (new static($files))
->filter(fn (string $path) => (new File())->isZipFile($disk, $path))
->filter(fn (string $path) => (new File)->isZipFile($disk, $path))
->map(fn (string $path) => new Backup($disk, $path))
->sortByDesc(fn (Backup $backup) => $backup->date()->timestamp)
->values();
Expand Down
2 changes: 1 addition & 1 deletion src/BackupDestination/BackupDestination.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class BackupDestination

protected ?BackupCollection $backupCollectionCache = null;

public function __construct(Filesystem $disk = null, string $backupName, string $diskName)
public function __construct(?Filesystem $disk, string $backupName, string $diskName)
{
$this->disk = $disk;

Expand Down
2 changes: 1 addition & 1 deletion src/BackupServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function registerDiscordChannel()
{
Notification::resolved(function (ChannelManager $service) {
$service->extend('discord', function ($app) {
return new DiscordChannel();
return new DiscordChannel;
});
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/Commands/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ListCommand extends BaseCommand
public function handle(): int
{
if (config()->has('backup.monitorBackups')) {
$this->warn("Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups.");
$this->warn('Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups.');
}

$statuses = BackupDestinationStatusFactory::createForMonitorConfig(config('backup.monitor_backups'));
Expand All @@ -39,8 +39,8 @@ protected function displayOverview(Collection $backupDestinationStatuses)
});

$this->table($headers, $rows, 'default', [
4 => new RightAlignedTableStyle(),
6 => new RightAlignedTableStyle(),
4 => new RightAlignedTableStyle,
6 => new RightAlignedTableStyle,
]);

return $this;
Expand Down Expand Up @@ -98,7 +98,7 @@ protected function displayFailures(Collection $backupDestinationStatuses)
return $this;
}

protected function getFormattedBackupDate(Backup $backup = null)
protected function getFormattedBackupDate(?Backup $backup = null)
{
return is_null($backup)
? 'No backups present'
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/MonitorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MonitorCommand extends BaseCommand implements Isolatable
public function handle(): int
{
if (config()->has('backup.monitorBackups')) {
$this->warn("Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups.");
$this->warn('Warning! Your config file still uses the old monitorBackups key. Update it to monitor_backups.');
}

$hasError = false;
Expand Down
3 changes: 1 addition & 2 deletions src/Events/BackupHasFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ class BackupHasFailed
public function __construct(
public Exception $exception,
public ?BackupDestination $backupDestination = null,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions src/Events/BackupManifestWasCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ class BackupManifestWasCreated
{
public function __construct(
public Manifest $manifest,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions src/Events/BackupWasSuccessful.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ class BackupWasSuccessful
{
public function __construct(
public BackupDestination $backupDestination,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions src/Events/BackupZipWasCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ class BackupZipWasCreated
{
public function __construct(
public string $pathToZip,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions src/Events/CleanupHasFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ class CleanupHasFailed
public function __construct(
public Exception $exception,
public ?BackupDestination $backupDestination = null,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions src/Events/CleanupWasSuccessful.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ class CleanupWasSuccessful
{
public function __construct(
public BackupDestination $backupDestination,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions src/Events/DumpingDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ class DumpingDatabase
{
public function __construct(
public DbDumper $dbDumper
) {
}
) {}
}
3 changes: 1 addition & 2 deletions src/Events/HealthyBackupWasFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ class HealthyBackupWasFound
{
public function __construct(
public BackupDestinationStatus $backupDestinationStatus,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions src/Events/UnhealthyBackupWasFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ class UnhealthyBackupWasFound
{
public function __construct(
public BackupDestinationStatus $backupDestinationStatus
) {
}
) {}
}
2 changes: 1 addition & 1 deletion src/Exceptions/CannotCreateDbDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CannotCreateDbDumper extends Exception
{
public static function unsupportedDriver(string $driver): self
{
$supportedDrivers = collect(config("database.connections"))->keys();
$supportedDrivers = collect(config('database.connections'))->keys();

$formattedSupportedDrivers = $supportedDrivers
->map(fn (string $supportedDriver) => "`$supportedDriver`")
Expand Down
1 change: 1 addition & 0 deletions src/Helpers/ConsoleOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* @phpstan-ignore-next-line
*
* @mixin \Illuminate\Console\Concerns\InteractsWithIO
*/
class ConsoleOutput
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function hasAllowedMimeType(?Filesystem $disk, string $path): bool
return in_array($this->mimeType($disk, $path), self::$allowedMimeTypes);
}

protected function mimeType(?Filesystem $disk, string $path): bool | string
protected function mimeType(?Filesystem $disk, string $path): bool|string
{
try {
if ($disk && method_exists($disk, 'mimeType')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/EncryptBackupArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function handle(BackupZipWasCreated $event): void
return;
}

$zip = new ZipArchive();
$zip = new ZipArchive;

$zip->open($event->pathToZip);

Expand Down
6 changes: 4 additions & 2 deletions src/Notifications/Channels/Discord/DiscordMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
class DiscordMessage
{
public const COLOR_SUCCESS = '0b6623';

public const COLOR_WARNING = 'fD6a02';

public const COLOR_ERROR = 'e32929';

protected string $username = 'Laravel Backup';
Expand All @@ -28,7 +30,7 @@ class DiscordMessage

protected string $url = '';

public function from(string $username, string $avatarUrl = null): self
public function from(string $username, ?string $avatarUrl = null): self
{
$this->username = $username;

Expand Down Expand Up @@ -128,7 +130,7 @@ public function toArray(): array
],
];

if (!empty($this->username)) {
if (! empty($this->username)) {
$data['username'] = $this->username;
}

Expand Down
5 changes: 2 additions & 3 deletions src/Notifications/EventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class EventHandler
{
public function __construct(
protected Repository $config
) {
}
) {}

public function subscribe(Dispatcher $events): void
{
Expand All @@ -40,7 +39,7 @@ protected function determineNotifiable()

protected function determineNotification($event): Notification
{
$lookingForNotificationClass = class_basename($event) . "Notification";
$lookingForNotificationClass = class_basename($event).'Notification';

$notificationClass = collect($this->config->get('backup.notifications.notifications'))
->keys()
Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/Notifiable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Notifiable
{
use NotifiableTrait;

public function routeNotificationForMail(): string | array
public function routeNotificationForMail(): string|array
{
return config('backup.notifications.mail.to');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ class BackupHasFailedNotification extends BaseNotification
{
public function __construct(
public BackupHasFailed $event,
) {
}
) {}

public function toMail(): MailMessage
{
$mailMessage = (new MailMessage())
$mailMessage = (new MailMessage)
->error()
->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name')))
->subject(trans('backup::notifications.backup_failed_subject', ['application_name' => $this->applicationName()]))
Expand All @@ -33,7 +32,7 @@ public function toMail(): MailMessage

public function toSlack(): SlackMessage
{
return (new SlackMessage())
return (new SlackMessage)
->error()
->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon'))
->to(config('backup.notifications.slack.channel'))
Expand All @@ -55,7 +54,7 @@ public function toSlack(): SlackMessage

public function toDiscord(): DiscordMessage
{
return (new DiscordMessage())
return (new DiscordMessage)
->error()
->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url'))
->title(trans('backup::notifications.backup_failed_subject', ['application_name' => $this->applicationName()]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ class BackupWasSuccessfulNotification extends BaseNotification
{
public function __construct(
public BackupWasSuccessful $event,
) {
}
) {}

public function toMail(): MailMessage
{
$mailMessage = (new MailMessage())
$mailMessage = (new MailMessage)
->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name')))
->subject(trans('backup::notifications.backup_successful_subject', ['application_name' => $this->applicationName()]))
->line(trans('backup::notifications.backup_successful_body', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()]));
Expand All @@ -32,7 +31,7 @@ public function toMail(): MailMessage

public function toSlack(): SlackMessage
{
return (new SlackMessage())
return (new SlackMessage)
->success()
->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon'))
->to(config('backup.notifications.slack.channel'))
Expand All @@ -44,7 +43,7 @@ public function toSlack(): SlackMessage

public function toDiscord(): DiscordMessage
{
return (new DiscordMessage())
return (new DiscordMessage)
->success()
->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url'))
->title(trans('backup::notifications.backup_successful_subject_title'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ class CleanupHasFailedNotification extends BaseNotification
{
public function __construct(
public CleanupHasFailed $event,
) {
}
) {}

public function toMail(): MailMessage
{
$mailMessage = (new MailMessage())
$mailMessage = (new MailMessage)
->error()
->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name')))
->subject(trans('backup::notifications.cleanup_failed_subject', ['application_name' => $this->applicationName()]))
Expand All @@ -35,7 +34,7 @@ public function toMail(): MailMessage

public function toSlack(): SlackMessage
{
return (new SlackMessage())
return (new SlackMessage)
->error()
->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon'))
->to(config('backup.notifications.slack.channel'))
Expand All @@ -57,7 +56,7 @@ public function toSlack(): SlackMessage

public function toDiscord(): DiscordMessage
{
return (new DiscordMessage())
return (new DiscordMessage)
->error()
->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url'))
->title(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ class CleanupWasSuccessfulNotification extends BaseNotification
{
public function __construct(
public CleanupWasSuccessful $event,
) {
}
) {}

public function toMail(): MailMessage
{
$mailMessage = (new MailMessage())
$mailMessage = (new MailMessage)
->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name')))
->subject(trans('backup::notifications.cleanup_successful_subject', ['application_name' => $this->applicationName()]))
->line(trans('backup::notifications.cleanup_successful_body', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()]));
Expand All @@ -32,7 +31,7 @@ public function toMail(): MailMessage

public function toSlack(): SlackMessage
{
return (new SlackMessage())
return (new SlackMessage)
->success()
->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon'))
->to(config('backup.notifications.slack.channel'))
Expand All @@ -44,7 +43,7 @@ public function toSlack(): SlackMessage

public function toDiscord(): DiscordMessage
{
return (new DiscordMessage())
return (new DiscordMessage)
->success()
->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url'))
->title(trans('backup::notifications.cleanup_successful_subject_title'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ class HealthyBackupWasFoundNotification extends BaseNotification
{
public function __construct(
public HealthyBackupWasFound $event,
) {
}
) {}

public function toMail(): MailMessage
{
$mailMessage = (new MailMessage())
$mailMessage = (new MailMessage)
->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name')))
->subject(trans('backup::notifications.healthy_backup_found_subject', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()]))
->line(trans('backup::notifications.healthy_backup_found_body', ['application_name' => $this->applicationName()]));
Expand All @@ -32,7 +31,7 @@ public function toMail(): MailMessage

public function toSlack(): SlackMessage
{
return (new SlackMessage())
return (new SlackMessage)
->success()
->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon'))
->to(config('backup.notifications.slack.channel'))
Expand All @@ -44,12 +43,12 @@ public function toSlack(): SlackMessage

public function toDiscord(): DiscordMessage
{
return (new DiscordMessage())
return (new DiscordMessage)
->success()
->from(config('backup.notifications.discord.username'), config('backup.notifications.discord.avatar_url'))
->title(
trans('backup::notifications.healthy_backup_found_subject_title', [
'application_name' => $this->applicationName(),
'application_name' => $this->applicationName(),
])
)->fields($this->backupDestinationProperties()->toArray());
}
Expand Down
Loading

0 comments on commit 5b67271

Please sign in to comment.