AssertKey   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 7
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A exists() 0 4 2
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Hydration\Mapping;
4
5
use Stratadox\HydrationMapping\Mapping;
6
use Stratadox\HydrationMapping\MappingFailure;
7
use function array_key_exists;
8
9
// In php, functions cannot be auto-loaded, hence the static class wrapping
10
final class AssertKey
11
{
12
    /** @throws MappingFailure */
13
    public static function exists(Mapping $mapping, array $data, string $key): void
14
    {
15
        if (!array_key_exists($key, $data)) {
16
            throw MissingTheKey::inTheInput($data, $mapping, $key);
17
        }
18
    }
19
}
20