Completed
Push — master ( d8ac6c...cd03ce )
by Jesse
02:57
created

MissingTheKey   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A inTheInput() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stratadox\Hydration\Mapping\Property;
6
7
use function sprintf;
8
use InvalidArgumentException as InvalidArgument;
9
use Stratadox\Hydration\MapsProperty;
10
use Stratadox\Hydration\UnmappableInput;
11
12
class MissingTheKey extends InvalidArgument implements UnmappableInput
13
{
14
    public static function inTheInput(array $data, MapsProperty $mapping, string $key) : UnmappableInput
15
    {
16
        return new self(sprintf(
17
            'Missing the key `%s` for property `%s` the input data: %s; Mapper: %s',
18
            $key,
19
            $mapping->name(),
20
            json_encode($data),
21
            get_class($mapping)
22
        ));
23
    }
24
}
25