has()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace BrenoRoosevelt;
5
6
/**
7
 * Determine if all given keys are present in the haystack.
8
 *
9
 * @param array $haystack The collection
10
 * @param string|int $key keys be to checked
11
 * @param string|int ...$keys keys be to checked
12
 * @return bool
13
 */
14
function has(array $haystack, $key, ...$keys): bool
15
{
16
    $keys[] = $key;
17
    return ! array_diff($keys, array_keys($haystack));
18
}
19