MandatoryOptionNotFoundException::missingOption()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
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
/**
15
 * Mandatory option not found exception
16
 *
17
 * Use this exception if a mandatory option was not found in the config
18
 */
19
class MandatoryOptionNotFoundException extends OutOfBoundsException
20
{
21 7
    public static function missingOption(iterable $dimensions, $option) : self
22
    {
23 7
        $depth = '';
24
25 7
        foreach ($dimensions as $dimension) {
26 7
            $depth .= '.' . $dimension;
27
        }
28 7
        return new static(
29 7
            sprintf('Mandatory option "%s" was not set for configuration "%s"', $option, $depth)
30
        );
31
    }
32
}
33