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

IterableIntGuard   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\IntBase;
7
use InputGuard\Guards\Bases\SingleIterableInput;
8
9
class IterableIntGuard implements Guard
10
{
11
    use ErrorMessagesBase;
12
    use IntBase {
13
        // Use the Iterable's validation as the primary validation logic and rename the Int validation method.
14
        SingleIterableInput::validation insteadof IntBase;
15
        IntBase::validation as intValidation;
16
    }
17
    use SingleIterableInput;
18
19 8
    public function __construct($input, ?iterable $default = null)
20
    {
21 8
        $this->input = $input;
22 8
        $this->value = $default;
23 8
    }
24
25 6
    protected function validateIterableElement($element, &$value): bool
26
    {
27 6
        return $this->intValidation($element, $value);
28
    }
29
}
30