Completed
Push — master ( 813469...d9bcbf )
by Travis
02:04
created

FloatGuard::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace InputGuard\Guards;
5
6
use InputGuard\Guards\Bases\FloatBase;
7
use InputGuard\Guards\Bases\SingleInput;
8
9
/**
10
 * This validates floating point numbers.
11
 *
12
 * Please be aware that it currently does not handle very large and very small numbers well. Additional research into
13
 * PHP's handling of floating point handling needs to be done. It turns out that floating points for all computers are
14
 * hard. Who knew?
15
 */
16
class FloatGuard implements Guard
17
{
18
    use ErrorMessagesBase;
19
    use FloatBase;
20
    use SingleInput;
21
22
    public function __construct($input, ?float $default = null)
23
    {
24
        $this->input = $input;
25
        $this->value = $default;
26
    }
27
28
    public function value(): ?float
29
    {
30
        $this->success();
31
32
        return $this->value;
33
    }
34
}
35