UnacceptableInput::illegal()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 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