Skip to content

Commit

Permalink
apply code styling from rector
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach committed Jun 7, 2024
1 parent 0c66d92 commit 65dfc97
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 25 deletions.
14 changes: 7 additions & 7 deletions resources/lang/fr/notifications.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

return [
'exception_message' => 'Message de l\'exception : :message',
'exception_trace' => 'Trace de l\'exception : :trace',
'exception_message_title' => 'Message de l\'exception',
'exception_trace_title' => 'Trace de l\'exception',
'exception_message' => "Message de l'exception : :message",
'exception_trace' => "Trace de l'exception : :trace",
'exception_message_title' => "Message de l'exception",
'exception_trace_title' => "Trace de l'exception",

'backup_failed_subject' => 'Échec de la sauvegarde de :application_name',
'backup_failed_body' => 'Important : Une erreur est survenue lors de la sauvegarde de :application_name',
Expand All @@ -27,14 +27,14 @@
'unhealthy_backup_found_subject' => 'Important : Les sauvegardes pour :application_name sont corrompues',
'unhealthy_backup_found_subject_title' => 'Important : Les sauvegardes pour :application_name sont corrompues. :problem',
'unhealthy_backup_found_body' => 'Les sauvegardes pour :application_name sur le disque :disk_name sont corrompues.',
'unhealthy_backup_found_not_reachable' => 'La destination de la sauvegarde n\'est pas accessible. :error',
'unhealthy_backup_found_empty' => 'Il n\'y a aucune sauvegarde pour cette application.',
'unhealthy_backup_found_not_reachable' => "La destination de la sauvegarde n'est pas accessible. :error",
'unhealthy_backup_found_empty' => "Il n'y a aucune sauvegarde pour cette application.",
'unhealthy_backup_found_old' => 'La dernière sauvegarde du :date est considérée trop vieille.',
'unhealthy_backup_found_unknown' => 'Désolé, une raison exacte ne peut être déterminée.',
'unhealthy_backup_found_full' => 'Les sauvegardes utilisent trop d\'espace disque. L\'utilisation actuelle est de :disk_usage alors que la limite autorisée est de :disk_limit.',

'no_backups_info' => 'Aucune sauvegarde n\'a encore été effectuée',
'application_name' => 'Nom de l\'application',
'application_name' => "Nom de l'application",
'backup_name' => 'Nom de la sauvegarde',
'disk' => 'Disque',
'newest_backup_size' => 'Taille de la sauvegarde la plus récente',
Expand Down
10 changes: 5 additions & 5 deletions resources/lang/it/notifications.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

return [
'exception_message' => 'Messaggio dell\'eccezione: :message',
'exception_trace' => 'Traccia dell\'eccezione: :trace',
'exception_message_title' => 'Messaggio dell\'eccezione',
'exception_trace_title' => 'Traccia dell\'eccezione',
'exception_message' => "Messaggio dell'eccezione: :message",
'exception_trace' => "Traccia dell'eccezione: :trace",
'exception_message_title' => "Messaggio dell'eccezione",
'exception_trace_title' => "Traccia dell'eccezione",

'backup_failed_subject' => 'Fallito il backup di :application_name',
'backup_failed_body' => 'Importante: Si è verificato un errore durante il backup di :application_name',
Expand Down Expand Up @@ -34,7 +34,7 @@
'unhealthy_backup_found_full' => 'I backup utilizzano troppa memoria. L\'utilizzo corrente è :disk_usage che è superiore al limite consentito di :disk_limit.',

'no_backups_info' => 'Non sono stati ancora effettuati backup',
'application_name' => 'Nome dell\'applicazione',
'application_name' => "Nome dell'applicazione",
'backup_name' => 'Nome di backup',
'disk' => 'Disco',
'newest_backup_size' => 'Dimensione backup più recente',
Expand Down
1 change: 1 addition & 0 deletions src/Commands/BackupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function handle(): int
if ($this->option('only-db')) {
$backupJob->dontBackupFilesystem();
}

if ($this->option('db-name')) {
$backupJob->onlyDbName($this->option('db-name'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function run(InputInterface $input, OutputInterface $output): int

protected function runningInConsole(): bool
{
return in_array(php_sapi_name(), ['cli', 'phpdbg']);
return in_array(PHP_SAPI, ['cli', 'phpdbg']);
}

public function getSubscribedSignals(): array
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/CannotCreateDbDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static function unsupportedDriver(string $driver): self
$supportedDrivers = collect(config('database.connections'))->keys();

$formattedSupportedDrivers = $supportedDrivers
->map(fn (string $supportedDriver) => "`$supportedDriver`")
->map(fn (string $supportedDriver) => "`{$supportedDriver}`")
->join(glue: ', ', finalGlue: ' or ');

return new static("Cannot create a dumper for db driver `{$driver}`. Use {$formattedSupportedDrivers}.");
Expand Down
1 change: 1 addition & 0 deletions src/Helpers/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static function humanReadableSize(float $sizeInBytes): string
if ($sizeInBytes === 0.0) {
return '0 '.$units[1];
}

for ($i = 0; $sizeInBytes > 1024; $i++) {
$sizeInBytes /= 1024;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/EncryptBackupArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected static function getAlgorithm(): ?int
$encryption = config('backup.backup.encryption');

if ($encryption === 'default') {
$encryption = defined("\ZipArchive::EM_AES_256")
$encryption = defined(\ZipArchive::class . '::EM_AES_256')
? ZipArchive::EM_AES_256
: null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function toMail(): MailMessage
->line(trans('backup::notifications.exception_message', ['message' => $this->event->exception->getMessage()]))
->line(trans('backup::notifications.exception_trace', ['trace' => $this->event->exception->getTraceAsString()]));

$this->backupDestinationProperties()->each(fn ($value, $name) => $mailMessage->line("{$name}: $value"));
$this->backupDestinationProperties()->each(fn ($value, $name) => $mailMessage->line("{$name}: {$value}"));

return $mailMessage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function toMail(): MailMessage
->line(trans('backup::notifications.backup_successful_body', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()]));

$this->backupDestinationProperties()->each(function ($value, $name) use ($mailMessage) {
$mailMessage->line("{$name}: $value");
$mailMessage->line("{$name}: {$value}");
});

return $mailMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function toMail(): MailMessage
->line(trans('backup::notifications.exception_trace', ['trace' => $this->event->exception->getTraceAsString()]));

$this->backupDestinationProperties()->each(function ($value, $name) use ($mailMessage) {
$mailMessage->line("{$name}: $value");
$mailMessage->line("{$name}: {$value}");
});

return $mailMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function toMail(): MailMessage
->line(trans('backup::notifications.cleanup_successful_body', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()]));

$this->backupDestinationProperties()->each(function ($value, $name) use ($mailMessage) {
$mailMessage->line("{$name}: $value");
$mailMessage->line("{$name}: {$value}");
});

return $mailMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function toMail(): MailMessage
->line(trans('backup::notifications.healthy_backup_found_body', ['application_name' => $this->applicationName()]));

$this->backupDestinationProperties()->each(function ($value, $name) use ($mailMessage) {
$mailMessage->line("{$name}: $value");
$mailMessage->line("{$name}: {$value}");
});

return $mailMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function toMail(): MailMessage
->line($this->problemDescription());

$this->backupDestinationProperties()->each(function ($value, $name) use ($mailMessage) {
$mailMessage->line("{$name}: $value");
$mailMessage->line("{$name}: {$value}");
});

if ($this->failure()->wasUnexpected()) {
Expand Down
3 changes: 2 additions & 1 deletion src/Tasks/Backup/FileSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function selectedFiles(): Generator|array
yield $includedFile;
}

if (! count($this->includedDirectories())) {
if ($this->includedDirectories() === []) {
return [];
}

Expand Down Expand Up @@ -107,6 +107,7 @@ protected function shouldExclude(string $path): bool
if (is_dir($path)) {
$path .= DIRECTORY_SEPARATOR;
}

foreach ($this->excludeFilesAndDirectories as $excludedPath) {
if (Str::startsWith($path, $excludedPath.(is_dir($excludedPath) ? DIRECTORY_SEPARATOR : ''))) {
if ($path != $excludedPath && is_file($excludedPath)) {
Expand Down
1 change: 1 addition & 0 deletions src/Tasks/Backup/Zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function add(string|iterable $files, ?string $nameInZip = null): self
);
}
}

$this->fileCount++;
}

Expand Down
11 changes: 11 additions & 0 deletions tests/Commands/BackupCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
foreach (range(0, $zip->numFiles - 1) as $i) {
$zipFiles[] = $zip->statIndex($i)['name'];
}

$zip->close();
sort($testFiles);
sort($zipFiles);
Expand All @@ -121,6 +122,7 @@
if ($zip->numFiles) {
$zipFile = $zip->statIndex(0)['name'];
}

$zip->close();

expect($zipFile)->toStartWith(ltrim((string) $this->getStubDirectory(), DIRECTORY_SEPARATOR));
Expand All @@ -132,6 +134,7 @@
if (! file_exists($tempDirectoryPath)) {
mkdir($tempDirectoryPath, 0777, true);
}

touch($tempDirectoryPath.DIRECTORY_SEPARATOR.'testing-file-temp.txt');

$this->artisan('backup:run --only-files')->assertExitCode(0);
Expand Down Expand Up @@ -367,8 +370,10 @@

$zip = new ZipArchive();
$zip->open(Storage::disk('local')->path($this->expectedZipPath));

expect($zip->numFiles)->toBe(1);
expect($zip->statIndex(0)['encryption_method'])->toBe(ZipArchive::EM_AES_256);

$zip->close();

Event::assertNotDispatched(BackupZipWasCreated::class);
Expand All @@ -382,8 +387,10 @@

$zip = new ZipArchive();
$zip->open(Storage::disk('local')->path($this->expectedZipPath));

expect($zip->numFiles)->toBe(1);
expect($zip->statIndex(0)['comp_method'])->toBe(ZipArchive::CM_DEFLATE);

$zip->close();

// check no compression with ZipArchive::CM_STORE method
Expand All @@ -394,8 +401,10 @@

$zip = new ZipArchive();
$zip->open(Storage::disk('local')->path($this->expectedZipPath));

expect($zip->numFiles)->toBe(1);
expect($zip->statIndex(0)['comp_method'])->toBe(ZipArchive::CM_STORE);

$zip->close();

// check ZipArchive::CM_DEFLATE method with custom compression level
Expand All @@ -406,8 +415,10 @@

$zip = new ZipArchive();
$zip->open(Storage::disk('local')->path($this->expectedZipPath));

expect($zip->numFiles)->toBe(1);
expect($zip->statIndex(0)['comp_method'])->toBe(ZipArchive::CM_DEFLATE);

$zip->close();
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Notifications/EventHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Spatie\Backup\BackupDestination\BackupDestinationFactory;
use Spatie\Backup\Events\BackupHasFailed;
use Spatie\Backup\Notifications\Notifiable;
use Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification as BackupHasFailedNotification;
use Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification;

beforeEach(function () {
Notification::fake();
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function seeInConsoleOutput(string $expectedText): void
$this->assertStringContainsString(
$expectedText,
$consoleOutput,
"Did not see `{$expectedText}` in console output: `$consoleOutput`"
"Did not see `{$expectedText}` in console output: `{$consoleOutput}`"
);
}

Expand All @@ -83,7 +83,7 @@ protected function doNotSeeInConsoleOutput(string $unexpectedText): void
$this->assertNotContains(
$unexpectedText,
$consoleOutput,
"Did not expect to see `{$unexpectedText}` in console output: `$consoleOutput`"
"Did not expect to see `{$unexpectedText}` in console output: `{$consoleOutput}`"
);
}

Expand Down

0 comments on commit 65dfc97

Please sign in to comment.