1 | <?php |
||
18 | abstract class FileSelection implements FileActionInterface |
||
19 | { |
||
20 | /** |
||
21 | * Object container |
||
22 | * @var \Iterator |
||
23 | */ |
||
24 | protected $iterator; |
||
25 | |||
26 | /** |
||
27 | * Whether we are in test mode or not |
||
28 | * |
||
29 | * @var boolean |
||
30 | */ |
||
31 | protected $isTestMode = false; |
||
32 | |||
33 | /** |
||
34 | * @var LoggerInterface |
||
35 | */ |
||
36 | protected $logger; |
||
37 | |||
38 | /** |
||
39 | * Holds all options |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | private $options = [ |
||
44 | 'maxAge' => 0, |
||
45 | 'pattern' => '', |
||
46 | 'recursive' => true, |
||
47 | 'maxDepth' => -1, |
||
48 | 'includeBrokenSymlink' => true, |
||
49 | // 'Filters' => [Filters\creationTimeFilterIterator], |
||
50 | ]; |
||
51 | |||
52 | /** |
||
53 | * @param bool $testMode Whether to enable test mode. Defaults to false |
||
54 | * @param LoggerInterface|null $logger |
||
55 | */ |
||
56 | public function __construct(bool $testMode = false, LoggerInterface $logger = null) |
||
65 | |||
66 | /** |
||
67 | * Sets the defaults |
||
68 | * |
||
69 | * @param array $options |
||
70 | * @return self |
||
71 | */ |
||
72 | private function setDefaults(array $options = []): self |
||
77 | |||
78 | /** |
||
79 | * Initializes the iterator and retrieves list of files |
||
80 | * |
||
81 | * @param string $path |
||
82 | * The path we want to check |
||
83 | * @param array $options |
||
84 | * Array with options, for now these are 'pattern', 'maxAge', 'recursive' and 'includeBrokenSymlink' |
||
85 | * @return FileActionInterface Returns same object for easy method concatenation |
||
86 | */ |
||
87 | public function constructFileList(string $path, array $options = []): FileActionInterface |
||
118 | |||
119 | /** |
||
120 | * Creates a JSON string with all filenames, no content, just filenames |
||
121 | */ |
||
122 | public function __toString(): string |
||
134 | } |
||
135 |