1 | <?php |
||
25 | class FileRepository implements WritableRepository |
||
26 | { |
||
27 | use Repository\Capability\Notify; |
||
28 | |||
29 | const DEFAULT_SLICE_SIZE = 1000; |
||
30 | |||
31 | /** |
||
32 | * @var RangeFileDirectory |
||
33 | */ |
||
34 | private $charactersDirectory; |
||
35 | |||
36 | /** |
||
37 | * @var PropertyFileDirectory |
||
38 | */ |
||
39 | private $propertiesDirectory; |
||
40 | |||
41 | /** |
||
42 | * @var PropertyAggregators|AggregatorRelay[] |
||
43 | */ |
||
44 | private $aggregators; |
||
45 | |||
46 | /** |
||
47 | * @var Serializer |
||
48 | */ |
||
49 | private $serializer; |
||
50 | |||
51 | /** |
||
52 | * @var int |
||
53 | */ |
||
54 | private $sliceSize; |
||
55 | |||
56 | /** |
||
57 | * @param RangeFileDirectory $charactersDirectory |
||
58 | * @param PropertyFileDirectory $propertiesDirectory |
||
59 | * @param PropertyAggregators $aggregators |
||
60 | * @param Serializer $serializer |
||
61 | * @param int $sliceSize |
||
62 | */ |
||
63 | public function __construct( |
||
76 | |||
77 | /** |
||
78 | * {@inheritDoc} |
||
79 | */ |
||
80 | public function getByCodepoint(Codepoint $codepoint) |
||
92 | |||
93 | /** |
||
94 | * {@inheritDoc} |
||
95 | */ |
||
96 | public function getByCodepoints(Codepoint\Collection $codepoints) |
||
102 | |||
103 | /** |
||
104 | * @param Codepoint\Collection $codepoints |
||
105 | * @return \Generator |
||
106 | */ |
||
107 | private function yieldByCodepoints(Codepoint\Collection $codepoints) |
||
117 | |||
118 | /** |
||
119 | * @param Codepoint $codepoint |
||
120 | * @return RangeFile |
||
121 | * @throws CharacterNotFoundException |
||
122 | */ |
||
123 | private function getFileByCodepoint(Codepoint $codepoint) |
||
133 | |||
134 | /** |
||
135 | * {@inheritDoc} |
||
136 | */ |
||
137 | public function addMany(Collection $characters) |
||
150 | |||
151 | /** |
||
152 | * @param Range $range |
||
153 | * @param CodepointAssigned[] $characters |
||
154 | * @return CodepointAssigned[] |
||
155 | */ |
||
156 | private function createFileWithCharacters(Range $range, array $characters) |
||
163 | |||
164 | /** |
||
165 | * @param CodepointAssigned[] $characters |
||
166 | * @return string[] |
||
167 | */ |
||
168 | private function flattenCharacters(array $characters) |
||
180 | |||
181 | /** |
||
182 | * @param Codepoint\Range\Collection[] $ranges |
||
183 | * @return string[] |
||
184 | */ |
||
185 | public function flattenRanges(array $ranges) |
||
196 | |||
197 | /** |
||
198 | * @param CodepointAssigned[] $characters |
||
199 | */ |
||
200 | private function addCharactersToAggregators(array $characters) |
||
204 | |||
205 | /** |
||
206 | * @return bool |
||
207 | */ |
||
208 | private function writeAggregations() |
||
216 | |||
217 | /** |
||
218 | * {@inheritDoc} |
||
219 | */ |
||
220 | public function getAll() |
||
226 | |||
227 | /** |
||
228 | * @return \Generator |
||
229 | */ |
||
230 | private function readAll() |
||
242 | |||
243 | /** |
||
244 | * {@inheritDoc} |
||
245 | */ |
||
246 | public function getCodepointsByBlock(Properties\General\Block $block) |
||
254 | |||
255 | /** |
||
256 | * {@inheritDoc} |
||
257 | */ |
||
258 | public function getCodepointsByCategory(Properties\General\GeneralCategory $category) |
||
266 | |||
267 | /** |
||
268 | * {@inheritDoc} |
||
269 | */ |
||
270 | public function getCodepointsByScript(Properties\General\Script $script) |
||
278 | |||
279 | /** |
||
280 | * @param Property $property |
||
281 | * @param string $key |
||
282 | * @param Exception $notFoundException |
||
283 | * @return Codepoint\Range[] |
||
284 | * @throws Exception |
||
285 | */ |
||
286 | private function resolveCodepointsByProperty(Property $property, $key, Exception $notFoundException) |
||
301 | |||
302 | /** |
||
303 | * {@inheritDoc} |
||
304 | */ |
||
305 | public function count() |
||
316 | } |