| Conditions | 3 |
| Paths | 2 |
| Total Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function parse(Definitions $definitions): TypeCollection |
||
| 15 | { |
||
| 16 | $types = array_filter($definitions |
||
| 17 | ->query('[typeof="rdfs:Class"]') |
||
| 18 | ->each(function (Crawler $crawler) { |
||
| 19 | return call_user_func(ParseType::fromCrawler($crawler)); |
||
| 20 | })); |
||
| 21 | |||
| 22 | $properties = array_filter($definitions |
||
| 23 | ->query('[typeof="rdf:Property"]') |
||
| 24 | ->each(function (Crawler $crawler) { |
||
| 25 | return call_user_func(ParseProperty::fromCrawler($crawler)); |
||
| 26 | })); |
||
| 27 | |||
| 28 | $constants = []; |
||
| 29 | |||
| 30 | foreach ($types as $type) { |
||
| 31 | $constants = array_merge($constants, array_filter($definitions |
||
| 32 | ->query('[typeof="'.$type->resource.'"]') |
||
| 33 | ->each(function (Crawler $crawler) use ($type) { |
||
| 34 | $constant = call_user_func(ParseConstant::fromCrawler($crawler)); |
||
| 35 | |||
| 36 | if (! is_null($constant)) { |
||
| 37 | $constant->type = $type->name; |
||
| 38 | } |
||
| 39 | |||
| 40 | return $constant; |
||
| 41 | }))); |
||
| 42 | } |
||
| 43 | |||
| 44 | return new TypeCollection($types, $properties, $constants); |
||
| 45 | } |
||
| 46 | } |
||
| 47 |