| Total Complexity | 12 |
| Total Lines | 82 |
| Duplicated Lines | 0 % |
| Coverage | 81.48% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | class Info |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | private $title; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private $id; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var array |
||
| 29 | */ |
||
| 30 | private $authors; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var array |
||
| 34 | */ |
||
| 35 | private $links; |
||
| 36 | |||
| 37 | 162 | public function __construct(SimpleXMLElement $node) |
|
| 38 | { |
||
| 39 | 162 | $this->authors = []; |
|
| 40 | 162 | $this->links = []; |
|
| 41 | |||
| 42 | /** @var SimpleXMLElement $child */ |
||
| 43 | 162 | foreach ($node->children() as $child) { |
|
| 44 | 160 | switch ($child->getName()) { |
|
| 45 | 160 | case 'author': |
|
| 46 | 160 | case 'contributor': |
|
| 47 | 42 | $author = new stdClass(); |
|
| 48 | /** @var SimpleXMLElement $authorNode */ |
||
| 49 | 42 | foreach ($child->children() as $authorNode) { |
|
| 50 | 42 | $author->{$authorNode->getName()} = (string) $authorNode; |
|
| 51 | } |
||
| 52 | 42 | $this->authors[] = $author; |
|
| 53 | 42 | break; |
|
| 54 | 160 | case 'link': |
|
| 55 | 42 | foreach ($child->attributes() as $attribute) { |
|
| 56 | 42 | if ($attribute->getName() === "value") { |
|
| 57 | $this->links[] = (string) $attribute; |
||
| 58 | } |
||
| 59 | } |
||
| 60 | 42 | break; |
|
| 61 | default: |
||
| 62 | 160 | $this->{$child->getName()} = (string) $child; |
|
| 63 | } |
||
| 64 | } |
||
| 65 | 162 | } |
|
| 66 | |||
| 67 | /** |
||
| 68 | * @return string |
||
| 69 | */ |
||
| 70 | 1 | public function getTitle() |
|
| 71 | { |
||
| 72 | 1 | return $this->title; |
|
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return string |
||
| 77 | */ |
||
| 78 | public function getId() |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @return array |
||
| 85 | */ |
||
| 86 | 1 | public function getAuthors() |
|
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @return array |
||
| 93 | */ |
||
| 94 | public function getLinks() |
||
| 99 |