CommandError::getOutputData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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