1 | <?php |
||
24 | class Database |
||
25 | { |
||
26 | /** |
||
27 | * @var Repository |
||
28 | */ |
||
29 | private $sourceRepository; |
||
30 | |||
31 | /** |
||
32 | * @param Repository $sourceRepository |
||
33 | */ |
||
34 | public function __construct(Repository $sourceRepository) |
||
35 | { |
||
36 | $this->sourceRepository = $sourceRepository; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return static |
||
41 | */ |
||
42 | public static function fromDisk() |
||
43 | { |
||
44 | return new static( |
||
45 | self::createFileRepository() |
||
46 | ); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @param Codepoint $codepoint |
||
51 | * @return CodepointAssigned |
||
52 | * @throws CharacterNotFoundException |
||
53 | * @throws InvalidArgumentException |
||
54 | * @throws OutOfRangeException |
||
55 | */ |
||
56 | public function getByCodepoint(Codepoint $codepoint) |
||
57 | { |
||
58 | return $this->sourceRepository |
||
59 | ->getByCodepoint($codepoint); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @param Codepoint\Collection $codepoints |
||
64 | * @return Character\Collection|CodepointAssigned[] |
||
65 | */ |
||
66 | public function getByCodepoints(Codepoint\Collection $codepoints) |
||
67 | { |
||
68 | return $this->sourceRepository |
||
69 | ->getByCodepoints($codepoints); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @param Codepoint $codepoint |
||
74 | * @return Character |
||
75 | * @throws CharacterNotFoundException |
||
76 | */ |
||
77 | public function getCharacterByCodepoint(Codepoint $codepoint) |
||
87 | |||
88 | /** |
||
89 | * @return Collection|CodepointAssigned[] |
||
90 | */ |
||
91 | public function all() |
||
96 | |||
97 | /** |
||
98 | * @return Collection|Character[] |
||
99 | */ |
||
100 | public function onlyCharacters() |
||
105 | |||
106 | /** |
||
107 | * @return Collection|NonCharacter[] |
||
108 | */ |
||
109 | public function onlyNonCharacters() |
||
114 | |||
115 | /** |
||
116 | * @return Collection|Surrogate[] |
||
117 | */ |
||
118 | public function onlySurrogates() |
||
123 | |||
124 | /** |
||
125 | * @param Block $block |
||
126 | * @throws Repository\BlockNotFoundException |
||
127 | * @return Codepoint\Range\Collection |
||
128 | */ |
||
129 | public function getCodepointsByBlock(Block $block) |
||
134 | |||
135 | /** |
||
136 | * @param Block $block |
||
137 | * @return Collection|CodepointAssigned[] |
||
138 | */ |
||
139 | public function getByBlock(Block $block) |
||
145 | |||
146 | /** |
||
147 | * @param GeneralCategory $category |
||
148 | * @throws Repository\BlockNotFoundException |
||
149 | * @return Codepoint\Range\Collection |
||
150 | */ |
||
151 | public function getCodepointsByCategory(GeneralCategory $category) |
||
156 | |||
157 | /** |
||
158 | * @param GeneralCategory $category |
||
159 | * @return Collection|CodepointAssigned[] |
||
160 | */ |
||
161 | public function getByCategory(GeneralCategory $category) |
||
167 | |||
168 | /** |
||
169 | * @param Codepoint\Range\Collection $ranges |
||
170 | * @return CodepointAssigned[] |
||
171 | */ |
||
172 | private function getByCodepointRanges(Codepoint\Range\Collection $ranges) |
||
178 | |||
179 | /** |
||
180 | * @return int |
||
181 | */ |
||
182 | public function getSize() |
||
186 | |||
187 | /** |
||
188 | * @return Repository |
||
189 | */ |
||
190 | private static function createFileRepository() |
||
201 | } |