UserList   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 13
eloc 26
dl 0
loc 67
c 0
b 0
f 0
ccs 29
cts 29
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A addItemUserCode() 0 10 1
A getDefaultDto() 0 3 1
B getXML() 0 30 10
A getImportRoot() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace kalanis\Pohoda;
6
7
/**
8
 * Definition of user-defined list
9
 *
10
 * @property UserList\UserListDto $data
11
 */
12
class UserList extends AbstractAgenda
13
{
14 1
    public function getImportRoot(): string
15
    {
16 1
        return 'lst:listUserCode';
17
    }
18
19
    /**
20
     * Add item user code.
21
     *
22
     * @param UserList\ItemUserCodeDto $data
23
     *
24
     * @return $this
25
     */
26 2
    public function addItemUserCode(UserList\ItemUserCodeDto $data): self
27
    {
28 2
        $itemUserCodes = new UserList\ItemUserCode($this->dependenciesFactory);
29 2
        $itemUserCodes
30 2
            ->setDirectionalVariable($this->useOneDirectionalVariables)
31 2
            ->setResolveOptions($this->resolveOptions)
32 2
            ->setData($data);
33 2
        $this->data->itemUserCodes[] = $itemUserCodes;
34
35 2
        return $this;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 2
    public function getXML(): \SimpleXMLElement
42
    {
43 2
        $xml = $this->createXML()->addChild('lst:listUserCode', '', $this->namespace('lst'));
44 2
        $xml->addAttribute('version', '1.1');
45 2
        $xml->addAttribute('code', strval($this->data->code));
46 2
        $xml->addAttribute('name', strval($this->data->name));
47
48 2
        if (!empty($this->data->dateTimeStamp) && is_string($this->data->dateTimeStamp)) {
49 1
            $xml->addAttribute('dateTimeStamp', $this->data->dateTimeStamp);
50
        }
51
52 2
        if (!empty($this->data->dateValidFrom) && is_string($this->data->dateValidFrom)) {
53 1
            $xml->addAttribute('dateValidFrom', $this->data->dateValidFrom);
54
        }
55
56 2
        if (isset($this->data->submenu)) {
57 1
            $xml->addAttribute('submenu', strval($this->data->submenu));
58
        }
59
60 2
        if (isset($this->data->constants) && 'true' == $this->data->constants) {
61 1
            $xml->addAttribute('constants', strval($this->data->constants));
62
        }
63
64 2
        if (!empty($this->data->itemUserCodes)) {
65 2
            foreach ($this->data->itemUserCodes as $itemUserCode) {
66 2
                $this->appendNode($xml, $itemUserCode->getXML());
67
            }
68
        }
69
70 2
        return $xml;
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76 3
    protected function getDefaultDto(): Common\Dtos\AbstractDto
77
    {
78 3
        return new UserList\UserListDto();
79
    }
80
}
81