BooleanAttribute::convertXmlValueToModelValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Xml\Impl\Type\Attribute;
4
5
use Xml\Impl\Util\ModelUtil;
6
use Xml\Type\ModelElementTypeInterface;
7
8
class BooleanAttribute extends AttributeImpl
9
{
10
    public function __construct(ModelElementTypeInterface $owningElementType)
11
    {
12
        parent::__construct($owningElementType);
13
    }
14
15
    /**
16
     * @return mixed
17
     */
18
    protected function convertXmlValueToModelValue(?string $rawValue)
19
    {
20
        return ModelUtil::valueAsBoolean($rawValue);
21
    }
22
23
    /**
24
     * @param mixed $modelValue;
25
     */
26
    protected function convertModelValueToXmlValue($modelValue): string
27
    {
28
        return $modelValue === null ? "false" : json_encode($modelValue);
29
    }
30
}
31