comparison vendor/consolidation/annotated-command/src/CommandError.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 }