Conditions | 8 |
Paths | 9 |
Total Lines | 28 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 23 |
CRAP Score | 8 |
Changes | 0 |
1 | <?php |
||
38 | 163 | public static function factory(SimpleXMLElement $node): Info |
|
39 | { |
||
40 | 163 | $authors = []; |
|
41 | 163 | $links = []; |
|
42 | 163 | $id = null; |
|
43 | 163 | $title = null; |
|
44 | 163 | foreach ($node->children() as $child) { |
|
45 | 161 | switch ($child->getName()) { |
|
46 | 161 | case 'author': |
|
47 | 161 | case 'contributor': |
|
48 | 41 | $author = new stdClass(); |
|
49 | /** @var SimpleXMLElement $authorNode */ |
||
50 | 41 | foreach ($child->children() as $authorNode) { |
|
51 | 41 | $author->{$authorNode->getName()} = (string) $authorNode; |
|
52 | } |
||
53 | 41 | $authors[] = $author; |
|
54 | 41 | break; |
|
55 | 161 | case 'link': |
|
56 | 41 | $links[] = (string) $child->attributes()['href']; |
|
57 | 41 | break; |
|
58 | 161 | case 'id': |
|
59 | 159 | $id = (string) $child; |
|
60 | 159 | break; |
|
61 | 161 | case 'title': |
|
62 | 161 | $title = (string) $child; |
|
63 | } |
||
64 | } |
||
65 | 163 | return new Info($id, $title, $authors, $links); |
|
66 | } |
||
108 |