| Total Complexity | 2 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | final class ExceptionTrackable implements Trackable |
||
| 24 | { |
||
| 25 | use TrackableMethods; |
||
| 26 | |||
| 27 | private Throwable $exception; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Creates a ExceptionTrackable |
||
| 31 | * |
||
| 32 | * @param Throwable $exception |
||
| 33 | * @param iterable $context |
||
| 34 | */ |
||
| 35 | public function __construct(Throwable $exception, iterable $context = []) |
||
| 36 | { |
||
| 37 | $this->message = $exception->getMessage(); |
||
| 38 | $this->exception = $exception; |
||
| 39 | $this->context = $context; |
||
| 40 | $this->logLevel = LogLevel::ALERT; |
||
| 41 | $this->label = Trackable::LABEL_EXCEPTION; |
||
| 42 | $this->context = array_merge($context, [ |
||
|
|
|||
| 43 | 'label' => $this->label, |
||
| 44 | 'exception' => get_class($this->exception), |
||
| 45 | 'file' => "{$exception->getFile()} ({$exception->getLine()})", |
||
| 46 | 'trace' => $this->exception->getTraceAsString() |
||
| 47 | ]); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * exception |
||
| 52 | * |
||
| 53 | * @return Throwable |
||
| 54 | */ |
||
| 55 | public function exception(): Throwable |
||
| 58 | } |
||
| 59 | } |
||
| 60 |