InvalidSettingsValue   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 47
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setFailedKey() 0 5 1
A getFailedKey() 0 3 1
A settingNotAllowed() 0 7 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(
26
            "Given value is not a registered allowed value for {$key}."
27
        );
28
29
        return $exception->setFailedKey($key);
30
    }
31
32
    /**
33
     * Set failed key name.
34
     *
35
     * @param string $key
36
     *
37
     * @return static
38
     */
39
    public function setFailedKey($key)
40
    {
41
        $this->failedKey = $key;
42
43
        return $this;
44
    }
45
46
    /**
47
     * Return failed key name.
48
     *
49
     * @return string
50
     */
51
    public function getFailedKey()
52
    {
53
        return $this->failedKey;
54
    }
55
}
56