Completed
Push — dev ( 7e1485...a1cea9 )
by Zach
02:25
created

InvalidSettingsValue   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 47
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A settingNotAllowed() 0 6 1
A setFailedKey() 0 6 1
A getFailedKey() 0 4 1
1
<?php
2
3
namespace LaravelPropertyBag\Exceptions;
4
5
use Exception;
6
7
class InvalidSettingsValue extends Exception
8
{
9
    /**
10
     * Failed key name.
11
     *
12
     * @var string
13
     */
14
    protected $failedKey;
15
16
    /**
17
     * Setting value is not definied in key's allowed values array.
18
     *
19
     * @param string $key
20
     *
21
     * @return static
22
     */
23
    public static function settingNotAllowed($key)
24
    {
25
        $exception = new static("Given value is not a registered allowed value for {$key}.");
26
27
        return $exception->setFailedKey($key);
28
    }
29
30
    /**
31
     * Sets failed key name.
32
     *
33
     * @param string $key
34
     *
35
     * @return static
36
     */
37
    public function setFailedKey($key)
38
    {
39
        $this->failedKey = $key;
40
41
        return $this;
42
    }
43
44
    /**
45
     * Returns failed key name.
46
     *
47
     * @return string
48
     */
49
    public function getFailedKey()
50
    {
51
        return $this->failedKey;
52
    }
53
}
54