UnacceptableInput   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A illegal() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Deserializer;
5
6
use InvalidArgumentException;
7
use function json_encode;
8
use function sprintf;
9
10
/**
11
 * Notifies the client that none of the hydration options accept the input.
12
 *
13
 * @author Stratadox
14
 */
15
final class UnacceptableInput extends InvalidArgumentException implements DeserializationFailure
16
{
17
    /**
18
     * Produces a deserialization exception to throw when none of the options
19
     * are satisfied by the input data.
20
     *
21
     * @param array $input       The input data that was not accepted.
22
     * @return DeserializationFailure The deserialization exception to throw.
23
     */
24
    public static function illegal(array $input): DeserializationFailure
25
    {
26
        return new UnacceptableInput(sprintf(
27
            'None of the deserializers are configured to accept `%s`.',
28
            json_encode($input)
29
        ));
30
    }
31
}
32