Total Complexity | 6 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
5 | final class NumberNode extends Node |
||
6 | { |
||
7 | private $value; |
||
8 | |||
9 | /** |
||
10 | * @param int|float $value |
||
11 | */ |
||
12 | public function __construct($value = 0, ?Document $ownerDocument = null) |
||
13 | { |
||
14 | parent::__construct($ownerDocument); |
||
15 | |||
16 | $this->setValue($value ?? 0); |
||
17 | } |
||
18 | |||
19 | /** |
||
20 | * @return int|float |
||
21 | */ |
||
22 | public function getValue() |
||
23 | { |
||
24 | return $this->value; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @param int|float $value |
||
29 | */ |
||
30 | public function setValue($value): void |
||
31 | { |
||
32 | if (!(\is_int($value) || \is_float($value))) { |
||
33 | throw new \TypeError('Number node value must be an integer or a double'); |
||
34 | } |
||
35 | |||
36 | $this->value = $value; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return int|float |
||
41 | */ |
||
42 | public function jsonSerialize() |
||
45 | } |
||
46 | } |
||
47 |