Skip to content

Commit 80ef3c3

Browse files
committed
chore: fix code style and static analysis
1 parent a21a95a commit 80ef3c3

7 files changed

Lines changed: 18 additions & 23 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"friendsofphp/php-cs-fixer": "^3.16"
4343
},
4444
"scripts": {
45-
"cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run",
45+
"cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --diff",
4646
"analyse": "vendor/bin/phpstan analyse",
4747
"test": "vendor/bin/phpunit"
4848
}

src/Command/BackupDatabasesCommand.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
use function array_splice;
2525
use function getcwd;
26+
use function implode;
2627
use function iterator_to_array;
2728
use function sprintf;
2829
use function Symfony\Component\String\u;
@@ -112,12 +113,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
112113
getcwd() :
113114
throw new RuntimeException('Unable to get the current directory, check the user permissions')
114115
;
115-
116+
116117
$dumpOnlyData = $backup->getStrategy()->getOnlyData();
117118
$backupTables = $backup->getStrategy()->getTables();
118-
119+
119120
$io->info(sprintf('The backup %s is in progress', $backupName));
120-
121+
121122
foreach ($connection->getDatabases() as $database) {
122123
if ($output->isVerbose()) {
123124
$io->comment("Backup for $database database has started");
@@ -127,13 +128,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
127128
$filePath = "$backupDirectory/$backupName-$database-$date.sql";
128129

129130
$process = Process::fromShellCommandline(
130-
\sprintf(
131+
sprintf(
131132
'"${:MYSQL_DUMP}" -u "${:DB_USER}" -h "${:DB_HOST}" -P "${:DB_PORT}" %s "${:DB_NAME}" %s > "${:FILEPATH}"',
132133
$dumpOnlyData ? '--no-create-info' : '',
133-
\implode(' ', $backupTables)
134+
implode(' ', $backupTables)
134135
)
135136
);
136-
137+
137138
$process->setPty(Process::isPtySupported());
138139
$process->run(null, [
139140
'MYSQL_DUMP' => $mysqldump,
@@ -144,7 +145,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
144145
'MYSQL_PWD' => $connection->getPassword(),
145146
'FILEPATH' => $filePath,
146147
]);
147-
148+
148149
if (!$process->isSuccessful()) {
149150
$message = '' !== $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
150151

src/Factory/Backup/BackupFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class BackupFactory implements NamedFactoryInterface
2020
*/
2121
public function __construct(
2222
private readonly ConnectionFactory $connectionFactory,
23-
private readonly FactoryInterface $strategyFactory
23+
private readonly FactoryInterface $strategyFactory,
2424
) {
2525
}
2626

src/Model/Backup/Backup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Backup
1111
public function __construct(
1212
private readonly string $name,
1313
private readonly Connection $connection,
14-
private readonly Strategy $strategy
14+
private readonly Strategy $strategy,
1515
) {
1616
}
1717

src/Model/Backup/Strategy.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,14 @@
77
class Strategy
88
{
99
/**
10-
* Default Constructor
11-
*
12-
* @param int $maxFiles
13-
* @param string $backupDirectory
14-
* @param string $dateFormat
15-
* @param bool $onlyData
16-
* @param array<string> $tables
10+
* @param list<string>|null $tables
1711
*/
1812
public function __construct(
1913
private readonly ?int $maxFiles = null,
2014
private readonly ?string $backupDirectory = null,
2115
private readonly ?string $dateFormat = 'Y-m-d',
2216
private readonly ?bool $onlyData = false,
23-
private readonly ?array $tables = null
17+
private readonly ?array $tables = null,
2418
) {
2519
}
2620

@@ -38,13 +32,13 @@ public function getDateFormat(): ?string
3832
{
3933
return $this->dateFormat;
4034
}
41-
35+
4236
public function getOnlyData(): ?bool
4337
{
4438
return $this->onlyData;
4539
}
46-
47-
/** @return array<string> */
40+
41+
/** @return list<string>|null */
4842
public function getTables(): ?array
4943
{
5044
return $this->tables;

src/Model/Connection/ConnectionDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum ConnectionDriver: string
1414
public function getConnectionClass(): string
1515
{
1616
return match ($this) {
17-
self::MySQL => MySQLConnection::class
17+
self::MySQL => MySQLConnection::class,
1818
};
1919
}
2020
}

src/Model/Connection/MySQLConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function __construct(
1414
private readonly ?string $password = null,
1515
private readonly ?string $host = '127.0.0.1',
1616
private readonly ?int $port = 3306,
17-
private readonly array $databases = []
17+
private readonly array $databases = [],
1818
) {
1919
}
2020

0 commit comments

Comments
 (0)