1 | <?php |
||
23 | class Local extends Collector |
||
24 | { |
||
25 | /** |
||
26 | * Backup target |
||
27 | * |
||
28 | * @var \phpbu\App\Backup\Target |
||
29 | */ |
||
30 | protected $target; |
||
31 | |||
32 | /** |
||
33 | * Target filename regex |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $fileRegex; |
||
38 | |||
39 | /** |
||
40 | * Collection cache |
||
41 | * |
||
42 | * @var \phpbu\App\Backup\File\Local[] |
||
43 | */ |
||
44 | protected $files; |
||
45 | |||
46 | /** |
||
47 | * Constructor |
||
48 | * |
||
49 | * @param \phpbu\App\Backup\Target $target |
||
50 | */ |
||
51 | 22 | public function __construct(Target $target) |
|
55 | |||
56 | /** |
||
57 | * Get all created backups. |
||
58 | * |
||
59 | * @return \phpbu\App\Backup\File\Local[] |
||
60 | */ |
||
61 | 9 | public function getBackupFiles() : array |
|
72 | |||
73 | /** |
||
74 | * Recursive backup collecting. |
||
75 | * |
||
76 | * @param string $path |
||
77 | * @param int $depth |
||
78 | */ |
||
79 | 9 | protected function collect(string $path, int $depth) |
|
97 | |||
98 | /** |
||
99 | * Collect backup files in directory. |
||
100 | * |
||
101 | * @param \DirectoryIterator $dirIterator |
||
102 | */ |
||
103 | 9 | protected function collectFiles(DirectoryIterator $dirIterator) |
|
119 | |||
120 | /** |
||
121 | * Check if the iterated file is part of a valid target path. |
||
122 | * |
||
123 | * @param \SplFileInfo $file |
||
124 | * @param int $depth |
||
125 | * @return bool |
||
126 | */ |
||
127 | 5 | protected function isValidDirectory(SplFileInfo $file, int $depth) |
|
131 | |||
132 | /** |
||
133 | * Does a directory match the respective target path. |
||
134 | * |
||
135 | * @param string $dir |
||
136 | * @param int $depth |
||
137 | * @return bool |
||
138 | */ |
||
139 | 5 | protected function isMatchingDirectory(string $dir, int $depth) |
|
145 | } |
||
146 |