CommandException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 4
c 4
b 0
f 1
lcom 0
cbo 0
dl 0
loc 48
rs 10
ccs 8
cts 8
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getHttpStatus() 0 8 2
A missingOptions() 0 7 1
A missingOption() 0 7 1
1
<?php
2
3
namespace Equip\Command;
4
5
use RuntimeException;
6
7
class CommandException extends RuntimeException
8
{
9
    const MISSING_OPTION = 2000;
10
11
    /*
12
     * @param array $names
13
     *
14
     * @return static
15
     *
16
     * @since 1.2.0
17
     */
18 2
    public static function missingOptions(array $names)
19
    {
20 2
        return new static(
21 2
            sprintf('Required options not defined: `%s`', implode('`, `', $names)),
22
            static::MISSING_OPTION
23 2
        );
24
    }
25
26
    /**
27
     * @param string $name
28
     *
29
     * @return static
30
     *
31
     * @deprecated 1.2.0
32
     */
33
    public static function missingOption($name)
34
    {
35
        return new static(
36
            sprintf('Required option `%s` is not defined', $name),
37
            static::MISSING_OPTION
38
        );
39
    }
40
41
    /**
42
     * Get the HTTP status for the exception.
43
     *
44
     * @return integer
45
     */
46 2
    public function getHttpStatus()
47
    {
48 2
        if ($this->getCode() === static::MISSING_OPTION) {
49 1
            return 400;
50
        }
51
52 1
        return 500;
53
    }
54
}
55