| 1 | <?php |
||
| 6 | abstract class Collector |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * Backup target |
||
| 10 | * |
||
| 11 | * @var \phpbu\App\Backup\Target |
||
| 12 | */ |
||
| 13 | protected $target; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Target filename regex |
||
| 17 | * |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | protected $fileRegex; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Collection cache |
||
| 24 | * |
||
| 25 | * @var \phpbu\App\Backup\File[] |
||
| 26 | */ |
||
| 27 | protected $files; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Setting up |
||
| 31 | * |
||
| 32 | * @param \phpbu\App\Backup\Target $target |
||
| 33 | */ |
||
| 34 | 4 | public function setUp(Target $target) |
|
| 35 | { |
||
| 36 | 4 | $this->target = $target; |
|
| 37 | 4 | $this->fileRegex = Str::datePlaceholdersToRegex($target->getFilenameRaw()); |
|
| 38 | 4 | $this->files = []; |
|
| 39 | 4 | } |
|
| 40 | |||
| 41 | /** |
||
| 42 | * Returns true if filename matches the target regex |
||
| 43 | * |
||
| 44 | * @param string $filename |
||
| 45 | * @return bool |
||
| 46 | */ |
||
| 47 | 13 | protected function isFilenameMatch(string $filename): bool |
|
| 51 | |||
| 52 | /** |
||
| 53 | * Get all created backups. |
||
| 54 | * |
||
| 55 | * @return \phpbu\App\Backup\File[] |
||
| 56 | */ |
||
| 57 | abstract public function getBackupFiles() : array; |
||
| 58 | } |