MissingConfigException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 45
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A getKey() 0 4 1
A getTrail() 0 4 1
1
<?php
2
3
namespace ClassConfig\Exceptions;
4
5
/**
6
 * Class MissingConfigException
7
 * @package ClassConfig\Exceptions
8
 */
9
class MissingConfigException extends \RuntimeException
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $key;
15
16
    /**
17
     * @var string[]
18
     */
19
    protected $trail;
20
21
    /**
22
     * MissingConfigException constructor.
23
     *
24
     * @param string[] $trail
25
     */
26
    public function __construct(array $trail)
27
    {
28
        $this->key = array_pop($trail);
29
        $this->trail = $trail;
30
31
        parent::__construct(sprintf(
32
            'Missing required config entry: "%s"%s.',
33
            $this->key,
34
            0 < count($this->trail) ? sprintf(' (%s)', implode('.', array_merge($this->trail, [$this->key]))) : ''
35
        ));
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getKey(): string
42
    {
43
        return $this->key;
44
    }
45
46
    /**
47
     * @return string[]
48
     */
49
    public function getTrail(): array
50
    {
51
        return $this->trail;
52
    }
53
}