Passed
Pull Request — master (#9)
by Shinji
10:53
created

InspectorSettingsException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrors() 0 4 1
A create() 0 6 2
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-profiler package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpProfiler\Inspector\Settings;
15
16
use LogicException;
17
18
abstract class InspectorSettingsException extends \Exception
19
{
20
    public const ERROR_NONE = 0;
21
22
    /** @var array<int, string> */
23
    protected const ERRORS = [
24
        self::ERROR_NONE => '',
25
    ];
26
27
    /**
28
     * @return array<int, string>
29
     */
30
    public static function getErrors(): array
31
    {
32
        /** @var array<int, string> */
33
        return static::ERRORS;
34
    }
35
36
    /**
37
     * @param int $error_no
38
     * @return static
39
     */
40
    public static function create(int $error_no): InspectorSettingsException
41
    {
42
        if (!isset(static::ERRORS[$error_no])) {
43
            throw new LogicException('wrong creation of CommandSettingException');
44
        }
45
        return new static(static::getErrors()[$error_no], $error_no);
46
    }
47
}
48