| Total Complexity | 10 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class DefaultIncidentHandler implements IncidentHandlerInterface |
||
| 10 | { |
||
| 11 | protected $type; |
||
| 12 | |||
| 13 | public function __construct(string $type) |
||
| 14 | { |
||
| 15 | $this->type = $type; |
||
| 16 | } |
||
| 17 | |||
| 18 | public function getIncidentHandlerType(): string |
||
| 19 | { |
||
| 20 | return $this->type; |
||
| 21 | } |
||
| 22 | |||
| 23 | public function handleIncident(IncidentContext $context, string $message): IncidentInterface |
||
| 24 | { |
||
| 25 | return $this->createIncident($context, $message); |
||
| 26 | } |
||
| 27 | |||
| 28 | public function createIncident(IncidentContext $context, string $message): IncidentInterface |
||
| 29 | { |
||
| 30 | $newIncident = IncidentEntity::createAndInsertIncident($this->type, $context, $message); |
||
| 31 | |||
| 32 | if ($context->getExecutionId() !== null) { |
||
|
|
|||
| 33 | $newIncident->createRecursiveIncidents(); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $newIncident; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function resolveIncident(IncidentContext $context): void |
||
| 42 | } |
||
| 43 | |||
| 44 | public function deleteIncident(IncidentContext $context): void |
||
| 45 | { |
||
| 46 | $this->removeIncident($context, false); |
||
| 47 | } |
||
| 48 | |||
| 49 | protected function removeIncident(IncidentContext $context, bool $incidentResolved): void |
||
| 61 | } |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 |