-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNumberNode.php
More file actions
46 lines (38 loc) · 859 Bytes
/
NumberNode.php
File metadata and controls
46 lines (38 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php declare(strict_types=1);
namespace DaveRandom\Jom;
final class NumberNode extends Node
{
private $value;
/**
* @param int|float $value
*/
public function __construct($value = 0, ?Document $ownerDocument = null)
{
parent::__construct($ownerDocument);
$this->setValue($value ?? 0);
}
/**
* @return int|float
*/
public function getValue()
{
return $this->value;
}
/**
* @param int|float $value
*/
public function setValue($value): void
{
if (!(\is_int($value) || \is_float($value))) {
throw new \TypeError('Number node value must be an integer or a double');
}
$this->value = $value;
}
/**
* @return int|float
*/
public function jsonSerialize()
{
return $this->value;
}
}