BooleanAttribute   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A convertModelValueToXmlValue() 0 3 2
A convertXmlValueToModelValue() 0 3 1
A __construct() 0 3 1
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