MissingIdentifyingColumn   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A inThe() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\TableLoader\Loader;
5
6
use InvalidArgumentException as InvalidArgument;
7
use function json_encode as encodeAsJson;
8
use function sprintf as withMessage;
9
10
/**
11
 * Notifies the client code that a required identifier is missing.
12
 *
13
 * @author Stratadox
14
 */
15
final class MissingIdentifyingColumn extends InvalidArgument implements CannotIdentifyEntity
16
{
17
    /**
18
     * Produces an exception for when the input data is missing a required
19
     * identifier column.
20
     *
21
     * @param array  $inputData     The data that lacks an identifier.
22
     * @param string $identifier    The identifier that is missing.
23
     * @return CannotIdentifyEntity The exception to throw.
24
     */
25
    public static function inThe(
26
        array $inputData,
27
        string $identifier
28
    ): CannotIdentifyEntity {
29
        return new MissingIdentifyingColumn(withMessage(
30
            'Missing the identifying column `%s` in the input data: %s',
31
            $identifier,
32
            encodeAsJson($inputData)
33
        ));
34
    }
35
}
36