xsBoolean   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fixValue() 0 11 3
A isOK() 0 3 1
1
<?php
2
3
namespace AlgoWeb\xsdTypes;
4
5
/**
6
 * The type xsd:boolean represents logical yes/no values.  The valid values for xsd:boolean are true, false, 0, and 1.
7
 * Values that are capitalized (e.g. TRUE) or abbreviated (e.g. T) are not valid.
8
 * @package AlgoWeb\xsdTypes
9
 */
10
class xsBoolean extends xsAnySimpleType
11
{
12
    /**
13
     * Construct.
14
     *
15
     * @param bool $value
16
     */
17
    public function __construct($value)
18
    {
19
        parent::__construct($value);
20
        $this->setWhiteSpaceFacet('collapse');
21
    }
22
23
    /**
24
     * @return void
25
     */
26
    protected function fixValue()
27
    {
28
        parent::fixValue();
29
30
        $this->value = filter_var($this->value, FILTER_VALIDATE_BOOLEAN, ['options' => [],
31
            'flags' => FILTER_NULL_ON_FAILURE]);
32
        if (null === $this->value) {
33
            throw new \InvalidArgumentException('the value passed to ' . get_class($this) . 'was not a booliean');
34
        }
35
        $this->value = $this->value ? 'true' : 'false';
36
    }
37
38
    /**
39
     * @return void
40
     */
41
    protected function isOK()
42
    {
43
    }
44
}
45