1 | <?php |
||
20 | abstract class Abstraction |
||
21 | { |
||
22 | /** |
||
23 | * Backup target |
||
24 | * |
||
25 | * @var \phpbu\App\Backup\Target |
||
26 | */ |
||
27 | protected $target; |
||
28 | |||
29 | /** |
||
30 | * Target filename regex |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $fileRegex; |
||
35 | |||
36 | /** |
||
37 | * Collection cache |
||
38 | * |
||
39 | * @var \phpbu\App\Backup\File\Local[] |
||
40 | */ |
||
41 | protected $files; |
||
42 | |||
43 | /** |
||
44 | * Indicates if current execution is a simulation. |
||
45 | * |
||
46 | * @var bool |
||
47 | */ |
||
48 | protected $isSimulation = false; |
||
49 | |||
50 | /** |
||
51 | * Index count for collected backups. |
||
52 | * |
||
53 | * @var int |
||
54 | */ |
||
55 | protected $index = 0; |
||
56 | |||
57 | /** |
||
58 | * Indicate that this is a simulation and make sure the collector includes a fake target. |
||
59 | * |
||
60 | * @param bool $isSimulation |
||
61 | */ |
||
62 | public function setSimulation(bool $isSimulation) |
||
66 | |||
67 | /** |
||
68 | * Get all created backups. |
||
69 | * |
||
70 | * @return \phpbu\App\Backup\File\Local[] |
||
71 | */ |
||
72 | public function getBackupFiles() : array |
||
91 | |||
92 | /** |
||
93 | * Collect all created backups. |
||
94 | * |
||
95 | * @return void |
||
96 | */ |
||
97 | abstract protected function collectBackups(); |
||
98 | |||
99 | /** |
||
100 | * Return an array index for a given file for key sorting the list later. |
||
101 | * |
||
102 | * @param \phpbu\App\Backup\File $file |
||
103 | * @return string |
||
104 | */ |
||
105 | protected function getFileIndex(File $file) : string |
||
109 | |||
110 | /** |
||
111 | * Returns true if filename matches the target regex |
||
112 | * |
||
113 | * @param string $filename |
||
114 | * @return bool |
||
115 | */ |
||
116 | protected function isFilenameMatch(string $filename) : bool |
||
120 | } |
||
121 |