-
-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1800 from spatie/feature/use-config-object
Migrate config to DTOs
- Loading branch information
Showing
50 changed files
with
725 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ composer.lock | |
vendor | ||
.phpunit.result.cache | ||
.php-cs-fixer.cache | ||
.phpunit.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Spatie\Backup\Config; | ||
|
||
use Spatie\Backup\Exceptions\InvalidConfig; | ||
use Spatie\Backup\Support\Data; | ||
|
||
class BackupConfig extends Data | ||
{ | ||
protected function __construct( | ||
public string $name, | ||
public SourceConfig $source, | ||
public ?string $databaseDumpCompressor, | ||
public ?string $databaseDumpFileTimestampFormat, | ||
public string $databaseDumpFilenameBase, | ||
public string $databaseDumpFileExtension, | ||
public DestinationConfig $destination, | ||
public ?string $temporaryDirectory, | ||
public ?string $password, | ||
public string $encryption, | ||
public int $tries, | ||
public int $retryDelay, | ||
public ?MonitoredBackupsConfig $monitoredBackups, | ||
) { | ||
if ($this->tries < 1) { | ||
throw InvalidConfig::integerMustBePositive('tries'); | ||
} | ||
} | ||
|
||
/** @param array<mixed> $data */ | ||
public static function fromArray(array $data): self | ||
{ | ||
$monitoredBackups = $data['monitored_backups'] ?? $data['monitorBackups'] ?? null; | ||
|
||
return new self( | ||
name: $data['name'], | ||
source: SourceConfig::fromArray($data['source']), | ||
databaseDumpCompressor: $data['database_dump_compressor'], | ||
databaseDumpFileTimestampFormat: $data['database_dump_file_timestamp_format'], | ||
databaseDumpFilenameBase: $data['database_dump_filename_base'], | ||
databaseDumpFileExtension: $data['database_dump_file_extension'], | ||
destination: DestinationConfig::fromArray($data['destination']), | ||
temporaryDirectory: $data['temporary_directory'] ?? null, | ||
password: $data['password'], | ||
encryption: $data['encryption'], | ||
tries: $data['tries'], | ||
retryDelay: $data['retry_delay'], | ||
monitoredBackups: $monitoredBackups ? MonitoredBackupsConfig::fromArray($monitoredBackups) : null, | ||
); | ||
} | ||
} |
Oops, something went wrong.