| 1 | <?php |
||
| 8 | class CheckResult |
||
| 9 | { |
||
| 10 | const STATUS_OK = 0; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var int |
||
| 14 | */ |
||
| 15 | protected $status; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var CheckException|null |
||
| 19 | */ |
||
| 20 | protected $error; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * CheckResult constructor. |
||
| 24 | * |
||
| 25 | * @param int $status |
||
| 26 | * @param CheckException $error |
||
| 27 | */ |
||
| 28 | 3 | public function __construct($status, CheckException $error = null) |
|
| 33 | |||
| 34 | /** |
||
| 35 | * @return CheckResult |
||
| 36 | */ |
||
| 37 | 1 | public static function okResult() |
|
| 41 | |||
| 42 | /** |
||
| 43 | * @param int $status |
||
| 44 | * @param CheckException $error |
||
| 45 | * |
||
| 46 | * @return CheckResult |
||
| 47 | */ |
||
| 48 | 2 | public static function errorResult($status, CheckException $error) |
|
| 52 | |||
| 53 | /** |
||
| 54 | * @return int |
||
| 55 | */ |
||
| 56 | 3 | public function getStatus() |
|
| 60 | |||
| 61 | /** |
||
| 62 | * @return CheckException|null |
||
| 63 | */ |
||
| 64 | 3 | public function getError() |
|
| 68 | |||
| 69 | /** |
||
| 70 | * @return bool |
||
| 71 | */ |
||
| 72 | 3 | public function isOk() |
|
| 76 | |||
| 77 | /** |
||
| 78 | * @param int $status |
||
| 79 | */ |
||
| 80 | 3 | protected function setStatus($status) |
|
| 84 | |||
| 85 | /** |
||
| 86 | * @param CheckException|null $error |
||
| 87 | */ |
||
| 88 | 3 | protected function setError(CheckException $error = null) |
|
| 92 | } |
||
| 93 |