Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| IncidentQueueEntity | |
0.00% |
0 / 11 |
|
0.00% |
0 / 7 |
72 | |
0.00% |
0 / 1 |
| getPayload | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| isDead | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isReady | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isDone | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| markDone | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| markFailed | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| markPending | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Modules\SupportModule\Entities; |
| 4 | |
| 5 | use CodeIgniter\Entity\Entity; |
| 6 | |
| 7 | class IncidentQueueEntity extends Entity |
| 8 | { |
| 9 | public const STATUS_PENDING = 'pending'; |
| 10 | public const STATUS_DONE = 'done'; |
| 11 | public const STATUS_FAILED = 'failed'; |
| 12 | |
| 13 | protected $dates = [ |
| 14 | 'created_at', |
| 15 | 'updated_at', |
| 16 | 'scheduled_at', |
| 17 | 'processed_at', |
| 18 | 'retry_at', |
| 19 | ]; |
| 20 | |
| 21 | protected $casts = [ |
| 22 | 'payload_json' => 'array', |
| 23 | 'attempts' => 'integer', |
| 24 | 'retry_count' => 'integer', |
| 25 | ]; |
| 26 | |
| 27 | public function getPayload(): array |
| 28 | { |
| 29 | $payload = $this->payload_json; |
| 30 | |
| 31 | return is_array($payload) ? $payload : []; |
| 32 | } |
| 33 | |
| 34 | public function isDead(): bool |
| 35 | { |
| 36 | return ($this->status ?? null) === self::STATUS_FAILED; |
| 37 | } |
| 38 | |
| 39 | public function isReady(): bool |
| 40 | { |
| 41 | return ($this->status ?? null) === self::STATUS_PENDING; |
| 42 | } |
| 43 | |
| 44 | public function isDone(): bool |
| 45 | { |
| 46 | return ($this->status ?? null) === self::STATUS_DONE; |
| 47 | } |
| 48 | |
| 49 | public function markDone(): self |
| 50 | { |
| 51 | $this->set('status', self::STATUS_DONE); |
| 52 | return $this; |
| 53 | } |
| 54 | |
| 55 | public function markFailed(): self |
| 56 | { |
| 57 | $this->set('status', self::STATUS_FAILED); |
| 58 | return $this; |
| 59 | } |
| 60 | |
| 61 | public function markPending(): self |
| 62 | { |
| 63 | $this->set('status', self::STATUS_PENDING); |
| 64 | return $this; |
| 65 | } |
| 66 | } |