Completed
Push — master ( 56127f...c3d14e )
by Travis
03:10
created

IterableFloatGuard   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validateIterableElement() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace InputGuard\Guards;
5
6
use InputGuard\Guards\Bases\FloatBase;
7
use InputGuard\Guards\Bases\SingleIterableInput;
8
9
class IterableFloatGuard implements Guard
10
{
11
    use ErrorMessagesBase;
12
    use FloatBase {
13
        // Use the Iterable's validation as the primary validation logic and rename the float validation method.
14
        SingleIterableInput::validation insteadof FloatBase;
15
        FloatBase::validation as floatValidation;
16
    }
17
    use SingleIterableInput;
18
19 7
    public function __construct($input, ?iterable $default = null)
20
    {
21 7
        $this->input = $input;
22 7
        $this->value = $default;
23 7
    }
24
25 5
    protected function validateIterableElement($element, &$value): bool
26
    {
27 5
        return $this->floatValidation($element, $value);
28
    }
29
}
30