Item::getXML()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 15
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 10
cc 3
nc 3
nop 0
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace kalanis\Pohoda\Order;
6
7
use kalanis\Pohoda\Common;
8
use kalanis\Pohoda\Document\AbstractItem;
9
use kalanis\PohodaException;
10
11
class Item extends AbstractItem
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 5
    public function getXML(): \SimpleXMLElement
17
    {
18 5
        if (is_null($this->namespace)) {
19 1
            throw new PohodaException('Namespace not set.');
20
        }
21
22 4
        if (is_null($this->nodePrefix)) {
23 1
            throw new PohodaException('Node name prefix not set.');
24
        }
25
26 3
        $xml = $this->createXML()->addChild($this->namespace . ':' . $this->nodePrefix . 'Item', '', $this->namespace($this->namespace));
27
28 3
        $this->addElements($xml, $this->getDataElements(), $this->namespace);
29
30 3
        return $xml;
31
    }
32
33
    /**
34
     * @{inheritDoc}
35
     */
36 5
    protected function getDefaultDto(): Common\Dtos\AbstractDto
37
    {
38 5
        return new ItemDto();
39
    }
40
}
41