CommandError   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 23
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getExitCode() 0 4 1
A getOutputData() 0 4 1
1
<?php
2
namespace Consolidation\AnnotatedCommand;
3
4
/**
5
 * Return a CommandError as the result of a command to pass a status
6
 * code and error message to be displayed.
7
 *
8
 * @package Consolidation\AnnotatedCommand
9
 */
10
class CommandError implements ExitCodeInterface, OutputDataInterface
11
{
12
    protected $message;
13
    protected $exitCode;
14
15
    public function __construct($message = null, $exitCode = 1)
16
    {
17
        $this->message = $message;
18
        // Ensure the exit code is non-zero. The exit code may have
19
        // come from an exception, and those often default to zero if
20
        // a specific value is not provided.
21
        $this->exitCode = $exitCode == 0 ? 1 : $exitCode;
22
    }
23
    public function getExitCode()
24
    {
25
        return $this->exitCode;
26
    }
27
28
    public function getOutputData()
29
    {
30
        return $this->message;
31
    }
32
}
33