1 | <?php |
||
48 | class VocabularyCache |
||
49 | { |
||
50 | /** |
||
51 | * Documents |
||
52 | * |
||
53 | * @var RemoteDocument[] |
||
54 | */ |
||
55 | protected $documents = []; |
||
56 | /** |
||
57 | * Vocabularies |
||
58 | * |
||
59 | * @var array |
||
60 | */ |
||
61 | protected $vocabularies = []; |
||
62 | /** |
||
63 | * Vocabulary prefices |
||
64 | * |
||
65 | * @var array |
||
66 | */ |
||
67 | protected $prefices = []; |
||
68 | /** |
||
69 | * Document cache slot |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | const SLOT_DOC = 'jsonld.doc'; |
||
74 | /** |
||
75 | * Vocabulary cache slot |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | const SLOT_VOCABS = 'jsonld.vocabs'; |
||
80 | |||
81 | /** |
||
82 | * Return a cached document |
||
83 | * |
||
84 | * @param string $url URL |
||
85 | * @return RemoteDocument|null Cached document |
||
86 | */ |
||
87 | 1 | public function getDocument($url) |
|
98 | |||
99 | /** |
||
100 | * Cache a document |
||
101 | * |
||
102 | * @param string $url URL |
||
103 | * @param RemoteDocument $document Document |
||
104 | * @return RemoteDocument Document |
||
105 | */ |
||
106 | 1 | public function setDocument($url, RemoteDocument $document) |
|
122 | |||
123 | /** |
||
124 | * Process a context vocabulary |
||
125 | * |
||
126 | * @param array $context Context |
||
127 | */ |
||
128 | 1 | protected function processContext(array $context) |
|
148 | |||
149 | /** |
||
150 | * Test if a vocabulary name or definition is a reserved term |
||
151 | * |
||
152 | * @param string $name Name |
||
153 | * @param string $definition Definition |
||
154 | * @return boolean Is reserved term |
||
155 | */ |
||
156 | 1 | protected function isReservedTokens($name, $definition) |
|
160 | |||
161 | /** |
||
162 | * Process a prefix / vocabulary term |
||
163 | * |
||
164 | * @param string $name Prefix name |
||
165 | * @param string|\stdClass $definition Definition |
||
166 | * @param array $prefices Prefix register |
||
167 | * @param array $vocabularies Vocabulary register |
||
168 | */ |
||
169 | 1 | protected function processPrefixVocabularyTerm($name, $definition, array &$prefices, array &$vocabularies) |
|
180 | |||
181 | /** |
||
182 | * Test whether this is a prefix and vocabulary definition |
||
183 | * |
||
184 | * @param string $name Prefix name |
||
185 | * @param string|\stdClass $definition Definition |
||
186 | * @param array $prefices Prefix register |
||
187 | * @return bool Is a prefix and vocabulary definition |
||
188 | */ |
||
189 | 1 | protected function isPrefix($name, $definition, array &$prefices) |
|
193 | |||
194 | /** |
||
195 | * Test whether this is a term definition |
||
196 | * |
||
197 | * @param string|\stdClass $definition Definition |
||
198 | * @return bool Is a term definition |
||
199 | */ |
||
200 | 1 | protected function isTerm($definition) |
|
204 | |||
205 | /** |
||
206 | * Process a vocabulary prefix |
||
207 | * |
||
208 | * @param string $name Prefix name |
||
209 | * @param string $definition Prefix definition |
||
210 | * @param array $prefices Prefix register |
||
211 | * @param array $vocabularies Vocabulary register |
||
212 | */ |
||
213 | 1 | protected function processPrefix($name, $definition, array &$prefices, array &$vocabularies) |
|
222 | |||
223 | /** |
||
224 | * Process a vocabulary term |
||
225 | * |
||
226 | * @param \stdClass $definition Term definition |
||
227 | * @param array $prefices Prefix register |
||
228 | * @param array $vocabularies Vocabulary register |
||
229 | */ |
||
230 | 1 | protected function processVocabularyTerm($definition, array &$prefices, array &$vocabularies) |
|
239 | |||
240 | /** |
||
241 | * Create an IRI from a name considering the known vocabularies |
||
242 | * |
||
243 | * @param string $name Name |
||
244 | * @return \stdClass IRI |
||
245 | */ |
||
246 | 2 | public function expandIRI($name) |
|
258 | |||
259 | /** |
||
260 | * Match a name with the known vocabularies |
||
261 | * |
||
262 | * @param string $name Name |
||
263 | * @param array $vocabularies Vocabularies |
||
264 | * @param \stdClass $iri IRI |
||
265 | */ |
||
266 | 1 | protected function matchVocabularies($name, array $vocabularies, &$iri) |
|
280 | |||
281 | /** |
||
282 | * Create a cache hash |
||
283 | * |
||
284 | * @param string $str String |
||
285 | * @param string $slot Slot |
||
286 | * @return string URL hash |
||
287 | */ |
||
288 | 1 | protected function getCacheHash($str, $slot) |
|
292 | } |
||
293 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.