SettingValueNotFoundException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
c 1
b 0
f 1
dl 0
loc 14
ccs 3
cts 3
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromName() 0 4 1
1
<?php
2
3
/**
4
 * Settings Manager
5
 *
6
 * @license http://opensource.org/licenses/MIT
7
 * @link https://github.com/caseyamcl/settings-manager
8
 * @package caseyamcl/settings-manager
9
 * @author Casey McLaughlin <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 *
14
 *  ------------------------------------------------------------------
15
 */
16
17
declare(strict_types=1);
18
19
namespace SettingsManager\Exception;
20
21
use RuntimeException;
22
use Throwable;
23
24
/**
25
 * Setting value not found exception
26
 *
27
 * Thrown when an implementing library calls `getValue()` or `getSettingValue()` for an undefined value.
28
 *
29
 * @author Casey McLaughlin <[email protected]>
30
 */
31
class SettingValueNotFoundException extends RuntimeException implements SettingException
32
{
33
    /**
34
     * Construct instance using setting name
35
     *
36
     * @param string $name
37
     * @param Throwable|null $prior
38
     * @param int $code
39
     * @return static
40
     */
41 12
    public static function fromName(string $name, ?Throwable $prior = null, int $code = 0)
42
    {
43 12
        $message = sprintf('Setting value not found: ' . $name);
44 12
        return new static($message, $code, $prior);
45
    }
46
}
47