Completed
Pull Request — master (#3)
by Woody
01:49
created

CommandException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A missingOption() 0 7 1
A getHttpStatus() 0 8 2
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 string $name
13
     *
14
     * @return static
15
     */
16 2
    public static function missingOption($name)
17
    {
18 2
        return new static(
19 2
            sprintf('Required option `%s` is not defined', $name),
20
            static::MISSING_OPTION
21 2
        );
22
    }
23
24
    /**
25
     * Get the HTTP status for the exception.
26
     *
27
     * @return integer
28
     */
29 2
    public function getHttpStatus()
30
    {
31 2
        if ($this->getCode() === static::MISSING_OPTION) {
32 1
            return 400;
33
        }
34
35 1
        return 500;
36
    }
37
}
38