1 | <?php |
||
13 | class Index implements \Countable, \IteratorAggregate |
||
14 | { |
||
15 | /** |
||
16 | * @var IndexNode |
||
17 | */ |
||
18 | protected $rootNode; |
||
19 | |||
20 | public function __construct() |
||
24 | |||
25 | /** |
||
26 | * Adds the given object to the index. |
||
27 | * |
||
28 | * @param IndexObject $indexObject |
||
29 | * @return Index |
||
30 | * @throws Exception |
||
31 | */ |
||
32 | public function addObject(IndexObject $indexObject): Index |
||
55 | |||
56 | /** |
||
57 | * Returns an index object by a given relative path. |
||
58 | * |
||
59 | * @param string $path |
||
60 | * @return IndexObject|null |
||
61 | */ |
||
62 | public function getObjectByPath(string $path): ?IndexObject |
||
68 | |||
69 | /** |
||
70 | * Returns an index object by a given blob id. |
||
71 | * |
||
72 | * @param string $blobId |
||
73 | * @return IndexObject|null |
||
74 | */ |
||
75 | public function getObjectByBlobId(string $blobId): ?IndexObject |
||
89 | |||
90 | /** |
||
91 | * Compares this index to the given index and returns the comparison result as boolean indicator. |
||
92 | * |
||
93 | * @param Index|null $other |
||
94 | * @param int $options |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function equals(Index $other = null, int $options = 0): bool |
||
106 | |||
107 | /** |
||
108 | * Returns true if this index is a subset of the given index. |
||
109 | * |
||
110 | * @param Index $other |
||
111 | * @param int $options |
||
112 | * @return bool |
||
113 | */ |
||
114 | public function isSubsetOf(Index $other, int $options = 0): bool |
||
128 | |||
129 | /** |
||
130 | * Returns the difference between this and the given index. |
||
131 | * The resulting difference contains objects from this index that are not present in or different to the |
||
132 | * corresponding object in the given index and objects from the given index that do not have a correspondence in |
||
133 | * this index. |
||
134 | * |
||
135 | * @param Index $other |
||
136 | * @param int $options |
||
137 | * @return IndexComparison |
||
138 | */ |
||
139 | public function getDifference(Index $other, int $options = 0): IndexComparison |
||
148 | |||
149 | /** |
||
150 | * Returns the intersection of this and the given index. |
||
151 | * |
||
152 | * @param Index $other |
||
153 | * @param int $options |
||
154 | * @return IndexComparison |
||
155 | */ |
||
156 | public function getIntersection(Index $other, int $options = 0): IndexComparison |
||
174 | |||
175 | /** |
||
176 | * Merges the given index into this index instance. |
||
177 | * Eventually existing objects with the same path are overridden. |
||
178 | * The contents of directories under the same path are merged together. |
||
179 | * |
||
180 | * @param Index $other |
||
181 | * @return Index |
||
182 | */ |
||
183 | public function merge(Index $other): Index |
||
208 | |||
209 | /** |
||
210 | * {@inheritdoc} |
||
211 | */ |
||
212 | public function count(): int |
||
216 | |||
217 | /** |
||
218 | * {@inheritdoc} |
||
219 | */ |
||
220 | public function getIterator(): \Traversable |
||
224 | |||
225 | /** |
||
226 | * Returns all those objects in this index that are not existent or are different in the given index. |
||
227 | * |
||
228 | * @param Index $other |
||
229 | * @param IndexComparison $indexDifference |
||
230 | * @param int $options |
||
231 | * @param bool $flipped |
||
232 | * @return IndexComparison |
||
233 | */ |
||
234 | protected function addDiffTo(Index $other, IndexComparison $indexDifference, int $options, bool $flipped): IndexComparison |
||
253 | } |
||
254 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: