Conditions | 6 |
Paths | 5 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
49 | 108 | private function buildLink($data): ? Link |
|
50 | { |
||
51 | 108 | if ($data === null) { |
|
52 | 6 | return null; |
|
53 | } |
||
54 | |||
55 | 108 | if (is_string($data)) { |
|
56 | 72 | return new Link($data); |
|
57 | } |
||
58 | |||
59 | 42 | if (!is_object($data)) { |
|
60 | 24 | throw new ValidationException(sprintf('Link has to be an object, string or null, "%s" given.', gettype($data))); |
|
61 | } |
||
62 | 18 | if (!property_exists($data, 'href')) { |
|
63 | 6 | throw new ValidationException('Link must have a "href" attribute.'); |
|
64 | } |
||
65 | |||
66 | 12 | return new Link($data->href, property_exists($data, 'meta') ? $this->metaParser->parse($data->meta) : null); |
|
67 | } |
||
69 |