@@ 7-27 (lines=21) @@ | ||
4 | ||
5 | use Innmind\Immutable\Exception\TypeException; |
|
6 | ||
7 | class FloatPrimitive implements PrimitiveInterface |
|
8 | { |
|
9 | private $value; |
|
10 | ||
11 | public function __construct($value) |
|
12 | { |
|
13 | if (!is_float($value)) { |
|
14 | throw new TypeException('Value must be a float'); |
|
15 | } |
|
16 | ||
17 | $this->value = (float) $value; |
|
18 | } |
|
19 | ||
20 | /** |
|
21 | * {@inheritdoc} |
|
22 | */ |
|
23 | public function toPrimitive() |
|
24 | { |
|
25 | return $this->value; |
|
26 | } |
|
27 | } |
|
28 |
@@ 7-27 (lines=21) @@ | ||
4 | ||
5 | use Innmind\Immutable\Exception\TypeException; |
|
6 | ||
7 | class IntegerPrimitive implements PrimitiveInterface |
|
8 | { |
|
9 | private $value; |
|
10 | ||
11 | public function __construct($value) |
|
12 | { |
|
13 | if (!is_int($value)) { |
|
14 | throw new TypeException('Value must be an integer'); |
|
15 | } |
|
16 | ||
17 | $this->value = (int) $value; |
|
18 | } |
|
19 | ||
20 | /** |
|
21 | * {@inheritdoc} |
|
22 | */ |
|
23 | public function toPrimitive() |
|
24 | { |
|
25 | return $this->value; |
|
26 | } |
|
27 | } |
|
28 |