Completed
Pull Request — master (#29)
by Sandro
06:42
created

UnexpectedValueException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 88.89%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
c 3
b 0
f 1
lcom 0
cbo 0
dl 0
loc 27
rs 10
ccs 8
cts 9
cp 0.8889

1 Method

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