Passed
Push — master ( 0b74cf...f6aee1 )
by Christopher
01:37
created

xsDecimal::fixValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace AlgoWeb\xsdTypes;
4
5
use AlgoWeb\xsdTypes\Facets\DigitsTrait;
6
use AlgoWeb\xsdTypes\Facets\MinMaxTrait;
7
8
/**
9
 * The type xsd:decimal represents a decimal number of arbitrary precision. Schema processors vary in the number of
10
 * significant digits they support, but a conforming processor must support a minimum of 18 significant digits.
11
 * The format of xsd:decimal is a sequence of digits optionally preceded by a sign ("+" or "-") and optionally
12
 * containing a period. The value may start or end with a period. If the fractional part is 0 then the period and
13
 * trailing zeros may be omitted. Leading and trailing zeros are permitted, but they are not considered significant.
14
 * That is, the decimal values 3.0 and 3.0000 are considered equal.
15
 * @package AlgoWeb\xsdTypes
16
 */
17
class xsDecimal extends xsAnySimpleType
18
{
19
    use DigitsTrait, MinMaxTrait;
20
21
    /**
22
     * Construct
23
     *
24
     * @param mixed $value
25
     */
26
    public function __construct($value)
27
    {
28
        parent::__construct($value);
29
        $this->setWhiteSpaceFacet("collapse");
30
    }
31
32
    protected function fixValue()
33
    {
34
        parent::fixValue();
35
        $this->__value = $this->fixFractionDigits($this->__value);
36
    }
37
38
    protected function isOK()
39
    {
40
        $this->checkDigitLength($this->__value);
41
        $this->checkFractionDigits($this->__value);
42
    }
43
}