1 | <?php |
||
10 | class FileIndexer implements FileIndexerInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var integer[] |
||
14 | */ |
||
15 | protected $index = []; |
||
16 | |||
17 | /** |
||
18 | * @var SplFileInfo[] |
||
19 | */ |
||
20 | protected $changes = []; |
||
21 | |||
22 | /** |
||
23 | * Index a given directory : add each found files (according to the given extension) to the index. |
||
24 | * |
||
25 | * @param array $directories |
||
26 | * @param array $extensions |
||
27 | * |
||
28 | * @throws Exception |
||
29 | */ |
||
30 | public function index(array $directories, array $extensions = []) |
||
62 | |||
63 | /** |
||
64 | * Add an entry to the indexer. If a entry already exists, it will also be added to the changes. |
||
65 | * |
||
66 | * @param SplFileInfo $splFileInfo |
||
67 | * |
||
68 | * @throws Exception |
||
69 | */ |
||
70 | public function add(SplFileInfo $splFileInfo) |
||
86 | |||
87 | /** |
||
88 | * Return an existing index entry. |
||
89 | * |
||
90 | * @param string $entryName |
||
91 | * |
||
92 | * @return SplFileInfo |
||
93 | * |
||
94 | * @throws Exception |
||
95 | */ |
||
96 | public function get($entryName) |
||
104 | |||
105 | /** |
||
106 | * Return true if the entry exists, false otherwise. |
||
107 | * |
||
108 | * @param $entryName |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function has($entryName) |
||
116 | |||
117 | /** |
||
118 | * Return true if the indexer has new changes since last index. |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | public function hasChangedEntries() |
||
126 | |||
127 | /** |
||
128 | * Return the changed entry since last index. |
||
129 | * |
||
130 | * @return SplFileInfo[] |
||
131 | */ |
||
132 | public function getChangedEntries() |
||
136 | } |
||
137 |