ItemUserCode   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
c 1
b 0
f 0
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getXML() 0 11 2
A configureOptions() 0 9 1
1
<?php
2
/**
3
 * This file is part of riesenia/pohoda package.
4
 *
5
 * Licensed under the MIT License
6
 * (c) RIESENIA.com
7
 */
8
9
declare(strict_types=1);
10
11
namespace Riesenia\Pohoda\UserList;
12
13
14
use Riesenia\Pohoda\AbstractAgenda;
15
use Riesenia\Pohoda\Common\OptionsResolver;
16
17
18
class ItemUserCode extends AbstractAgenda
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23 2
    public function getXML(): \SimpleXMLElement
24
    {
25 2
        $xml = $this->createXML()->addChild('lst:itemUserCode', '', $this->namespace('lst'));
26 2
        $xml->addAttribute('code', strval($this->data['code']));
27 2
        $xml->addAttribute('name', strval($this->data['name']));
28
29 2
        if (isset($this->data['constant'])) {
30 1
            $xml->addAttribute('constant', strval($this->data['constant']));
31
        }
32
33 2
        return $xml;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 1
    protected function configureOptions(OptionsResolver $resolver): void
40
    {
41
        // available options
42 1
        $resolver->setDefined(['code', 'name', 'constant']);
43
44
        // validate / format options
45 1
        $resolver->setRequired('code');
46 1
        $resolver->setRequired('name');
47 1
        $resolver->setNormalizer('constant', $this->normalizerFactory->getClosure('int'));
48
    }
49
}
50