Conditions | 3 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
38 | 12 | public function asXML(): SimpleXMLElement |
|
39 | { |
||
40 | 12 | $infinity = $this->infinity ? 'type="infinity"' : ''; |
|
41 | |||
42 | 12 | $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><yandex:related ' |
|
43 | 12 | . $infinity . '></yandex:related>', |
|
44 | 12 | LIBXML_NOERROR | LIBXML_ERR_NONE | LIBXML_ERR_FATAL); |
|
45 | |||
46 | 12 | foreach ($this->relatedItems as $item) { |
|
47 | 3 | $toDom = dom_import_simplexml($xml); |
|
48 | 3 | $fromDom = dom_import_simplexml($item->asXML()); |
|
49 | 3 | $toDom->appendChild($toDom->ownerDocument->importNode($fromDom, true)); |
|
50 | } |
||
51 | |||
52 | 12 | return $xml; |
|
53 | } |
||
54 | } |
||
55 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.