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

IterableIntGuard::validateIterableElement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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\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