Passed
Push — master ( d898ef...46a72e )
by Christopher
02:06 queued 27s
created

xsBoolean::isOK()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
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
    protected function isOK()
24
    {
25
        if (boolval($this->__value) !== $this->__value) {
26
            throw new \InvalidArgumentException(
27
                "the provided value for " . __CLASS__ . " needs to be a boolean: "
28
            );
29
        }
30
    }
31
}
32