| Total Complexity | 6 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | abstract class MongoJob extends AbstractJob implements ResultProviderInterface |
||
| 23 | { |
||
| 24 | protected $result; |
||
| 25 | |||
| 26 | public function setResult(JobResult $result) : void |
||
| 27 | { |
||
| 28 | $this->result = $result; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function getResult() : JobResult |
||
| 32 | { |
||
| 33 | if (!$this->result) { |
||
| 34 | $this->setResult(new JobResult(ProcessJobEvent::JOB_STATUS_UNKNOWN)); |
||
| 35 | } |
||
| 36 | |||
| 37 | return $this->result; |
||
| 38 | } |
||
| 39 | |||
| 40 | protected function failure(string $message, ?array $extra = null) : int |
||
| 41 | { |
||
| 42 | $this->setResult(JobResult::failure($message, $extra)); |
||
| 43 | |||
| 44 | return ProcessJobEvent::JOB_STATUS_FAILURE; |
||
| 45 | } |
||
| 46 | |||
| 47 | protected function recoverable(string $message, array $options = []) : int |
||
| 48 | { |
||
| 49 | $this->setResult(JobResult::recoverable($message, $options)); |
||
| 50 | |||
| 51 | return ProcessJobEvent::JOB_STATUS_FAILURE_RECOVERABLE; |
||
| 52 | } |
||
| 53 | |||
| 54 | protected function success(?string $message = null, ?array $extra = null) : int |
||
| 59 | } |
||
| 60 | } |
||
| 61 |