UnexpectedValueException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 11
c 1
b 0
f 1
dl 0
loc 23
ccs 9
cts 10
cp 0.9
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A invalidOptions() 0 16 3
1
<?php
2
/**
3
 * Sandro Keil (https://sandro-keil.de)
4
 *
5
 * @link      http://github.com/sandrokeil/interop-config for the canonical source repository
6
 * @copyright Copyright (c) 2015-2020 Sandro Keil
7
 * @license   http://github.com/sandrokeil/interop-config/blob/master/LICENSE.md New BSD License
8
 */
9
10
declare(strict_types = 1);
11
12
namespace Interop\Config\Exception;
13
14
use UnexpectedValueException as PhpUnexpectedValueException;
15
16
/**
17
 * UnexpectedValueException exception
18
 *
19
 * Use this exception if a value is outside a set of values.
20
 */
21
class UnexpectedValueException extends PhpUnexpectedValueException implements ExceptionInterface
22
{
23
    /**
24
     * @param iterable $dimensions
25
     * @param mixed $currentDimension Current configuration key
26
     * @return UnexpectedValueException
27
     */
28 1
    public static function invalidOptions(iterable $dimensions, $currentDimension = null) : self
29
    {
30 1
        $position = [];
31
32 1
        foreach ($dimensions as $dimension) {
33 1
            if ($dimension === $currentDimension) {
34
                break;
35
            }
36 1
            $position[] = $dimension;
37
        }
38
39 1
        return new static(
40 1
            sprintf(
41
                'Configuration must either be of type "array" or implement "\ArrayAccess". ' .
42 1
                'Configuration position is "%s"',
43 1
                rtrim(implode('.', $position), '.')
44
            )
45
        );
46
    }
47
}
48