TCheckArrayRange   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkValue() 0 6 2
A checkRule() 0 6 2
1
<?php
2
3
namespace kalanis\kw_rules\Rules;
4
5
6
use kalanis\kw_rules\Exceptions\RuleException;
7
8
9
/**
10
 * trait TCheckArrayRange
11
 * @package kalanis\kw_rules\Rules
12
 * Check original values as array of ranges
13
 */
14
trait TCheckArrayRange
15
{
16
    use TRule;
17
18
    /**
19
     * @param mixed|null $againstValue
20
     * @throws RuleException
21
     * @return array<array<int>>
22
     */
23 8
    protected function checkValue($againstValue)
24
    {
25 8
        if (!is_array($againstValue)) {
26 1
            throw new RuleException('No array found. Need set input as array!');
27
        }
28 7
        return array_map([$this, 'checkRule'], $againstValue);
29
    }
30
31
    /**
32
     * @param mixed|null $againstValue
33
     * @throws RuleException
34
     * @return array<int>
35
     */
36 7
    protected function checkRule($againstValue): array
37
    {
38 7
        if (!is_array($againstValue)) {
39 1
            throw new RuleException('No array found. Need set both values to compare!');
40
        }
41 6
        return array_map('intval', $againstValue);
42
    }
43
}
44