Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| IncidentEntity | |
0.00% |
0 / 8 |
|
0.00% |
0 / 6 |
56 | |
0.00% |
0 / 1 |
| isCritical | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isSystem | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSafeMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPayload | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| markResolved | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| isResolved | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Modules\SupportModule\Entities; |
| 4 | |
| 5 | use CodeIgniter\Entity\Entity; |
| 6 | |
| 7 | class IncidentEntity extends Entity |
| 8 | { |
| 9 | public const STATUS_RESOLVED = 'resolved'; |
| 10 | |
| 11 | public const SEVERITY_CRITICAL = 'critical'; |
| 12 | public const SOURCE_SYSTEM = 'system'; |
| 13 | |
| 14 | protected $dates = [ |
| 15 | 'created_at', |
| 16 | 'updated_at', |
| 17 | ]; |
| 18 | |
| 19 | protected $casts = [ |
| 20 | 'payload_json' => 'array', |
| 21 | ]; |
| 22 | |
| 23 | public function isCritical(): bool |
| 24 | { |
| 25 | return ($this->severity ?? null) === self::SEVERITY_CRITICAL; |
| 26 | } |
| 27 | |
| 28 | public function isSystem(): bool |
| 29 | { |
| 30 | return ($this->source ?? null) === self::SOURCE_SYSTEM; |
| 31 | } |
| 32 | |
| 33 | public function getSafeMessage(): string |
| 34 | { |
| 35 | return (string) ($this->message ?? 'Unknown incident'); |
| 36 | } |
| 37 | |
| 38 | public function getPayload(): array |
| 39 | { |
| 40 | $payload = $this->payload_json; |
| 41 | |
| 42 | return is_array($payload) ? $payload : []; |
| 43 | } |
| 44 | |
| 45 | public function markResolved(): self |
| 46 | { |
| 47 | $this->set('status', self::STATUS_RESOLVED); |
| 48 | return $this; |
| 49 | } |
| 50 | |
| 51 | public function isResolved(): bool |
| 52 | { |
| 53 | return ($this->status ?? null) === self::STATUS_RESOLVED; |
| 54 | } |
| 55 | } |