1 | <?php |
||
20 | class Collector |
||
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 | 7 | * |
|
39 | * @var \phpbu\App\Backup\File[] |
||
40 | 7 | */ |
|
41 | 7 | protected $files; |
|
42 | |||
43 | /** |
||
44 | * Constructor |
||
45 | * |
||
46 | * @param Target $target |
||
47 | */ |
||
48 | 7 | public function __construct(Target $target) |
|
52 | |||
53 | 7 | /** |
|
54 | 7 | * Get all created backups. |
|
55 | 7 | * |
|
56 | * @return \phpbu\App\Backup\File[] |
||
57 | */ |
||
58 | public function getBackupFiles() |
||
69 | 4 | ||
70 | 4 | /** |
|
71 | 4 | * Recursive backup collecting. |
|
72 | * |
||
73 | * @param string $path |
||
74 | 4 | * @param int $depth |
|
75 | 4 | */ |
|
76 | 4 | protected function collect($path, $depth) |
|
94 | 7 | ||
95 | 7 | /** |
|
96 | 7 | * Collect backup files in directory. |
|
97 | 7 | * |
|
98 | * @param \DirectoryIterator $dirIterator |
||
99 | 7 | */ |
|
100 | protected function collectFiles(DirectoryIterator $dirIterator) |
||
116 | |||
117 | /** |
||
118 | * Check if the iterated file is part of a valid target path. |
||
119 | * |
||
120 | * @param \SplFileInfo $file |
||
121 | * @param int $depth |
||
122 | * @return bool |
||
123 | */ |
||
124 | protected function isValidDirectory(SplFileInfo $file, $depth) |
||
128 | |||
129 | /** |
||
130 | * Does a directory match the respective target path. |
||
131 | * |
||
132 | * @param string $dir |
||
133 | * @param int $depth |
||
134 | * @return bool |
||
135 | */ |
||
136 | protected function isMatchingDirectory($dir, $depth) |
||
142 | } |
||
143 |