PathLeadsNowhere   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A didNotFind() 0 11 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Json;
5
6
use function implode;
7
use OutOfBoundsException as OutOfBounds;
8
use function sprintf;
9
10
/**
11
 * Exception to notify that the location could not be accessed because it does
12
 * not exist.
13
 *
14
 * @author Stratadox
15
 */
16
final class PathLeadsNowhere extends OutOfBounds implements InvalidOffset
17
{
18
    public static function didNotFind(
19
        string $missingKey,
20
        Json $data,
21
        string ...$path
22
    ): self {
23
        return new self(sprintf(
24
            'Could not find the value for `%s` in the json data `%s`: ' .
25
            'the key `%s` does not exist.',
26
            implode(' -> ', $path),
27
            $data,
28
            $missingKey
29
        ));
30
    }
31
}
32