Mercurial > hg > isophonics-drupal-site
annotate vendor/consolidation/annotated-command/src/CommandError.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 namespace Consolidation\AnnotatedCommand; |
Chris@0 | 3 |
Chris@0 | 4 /** |
Chris@0 | 5 * Return a CommandError as the result of a command to pass a status |
Chris@0 | 6 * code and error message to be displayed. |
Chris@0 | 7 * |
Chris@0 | 8 * @package Consolidation\AnnotatedCommand |
Chris@0 | 9 */ |
Chris@0 | 10 class CommandError implements ExitCodeInterface, OutputDataInterface |
Chris@0 | 11 { |
Chris@0 | 12 protected $message; |
Chris@0 | 13 protected $exitCode; |
Chris@0 | 14 |
Chris@0 | 15 public function __construct($message = null, $exitCode = 1) |
Chris@0 | 16 { |
Chris@0 | 17 $this->message = $message; |
Chris@0 | 18 // Ensure the exit code is non-zero. The exit code may have |
Chris@0 | 19 // come from an exception, and those often default to zero if |
Chris@0 | 20 // a specific value is not provided. |
Chris@0 | 21 $this->exitCode = $exitCode == 0 ? 1 : $exitCode; |
Chris@0 | 22 } |
Chris@0 | 23 public function getExitCode() |
Chris@0 | 24 { |
Chris@0 | 25 return $this->exitCode; |
Chris@0 | 26 } |
Chris@0 | 27 |
Chris@0 | 28 public function getOutputData() |
Chris@0 | 29 { |
Chris@0 | 30 return $this->message; |
Chris@0 | 31 } |
Chris@0 | 32 } |