Passed
Push — master ( f519e1...ef65fe )
by Brian
02:51
created

Arr   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isAssoc() 0 7 2
A keysDiff() 0 7 2
1
<?php
2
3
namespace Bmatovu\Ussd\Support;
4
5
class Arr
6
{
7
    /**
8
     * @see https://stackoverflow.com/a/173479/2732184
9
     */
10
    public static function isAssoc(array $arr): bool
11
    {
12
        if ([] === $arr) {
13
            return false;
14
        }
15
16
        return array_keys($arr) !== range(0, \count($arr) - 1);
17
    }
18
19
    public static function keysDiff(array $required, array $given): array
20
    {
21
        if (self::isAssoc($given)) {
22
            $given = array_keys($given);
23
        }
24
25
        return array_diff($required, $given);
26
    }
27
}
28