Category::configureOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * This file is part of riesenia/pohoda package.
5
 *
6
 * Licensed under the MIT License
7
 * (c) RIESENIA.com
8
 */
9
10
declare(strict_types=1);
11
12
namespace Riesenia\Pohoda\Stock;
13
14
use Riesenia\Pohoda\AbstractAgenda;
15
use Riesenia\Pohoda\Common\OptionsResolver;
16
17
class Category extends AbstractAgenda
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 1
    public function getXML(): \SimpleXMLElement
23
    {
24 1
        $category = $this->data['idCategory'] ?? null;
25 1
        return $this->createXML()->addChild(
26 1
            'stk:idCategory',
27 1
            is_null($category) ? null : strval($category),
28 1
            $this->namespace('stk'),
29 1
        );
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 1
    protected function configureOptions(OptionsResolver $resolver): void
36
    {
37
        // available options
38 1
        $resolver->setDefined(['idCategory']);
39
40
        // validate / format options
41 1
        $resolver->setRequired('idCategory');
42 1
        $resolver->setNormalizer('idCategory', $this->normalizerFactory->getClosure('int'));
43
    }
44
}
45