SettingValueNotFoundException::fromName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 3
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
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