| Total Complexity | 3 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 23 | abstract class AbstractException extends RuntimeException implements ExceptionInterface |
||
| 24 | { |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Context of the exception |
||
| 28 | * |
||
| 29 | * @var array |
||
| 30 | */ |
||
| 31 | private $context = []; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Constructor of the exception |
||
| 35 | * |
||
| 36 | * @param string $message |
||
| 37 | * @param array $context |
||
| 38 | * @param int $code |
||
| 39 | * @param Throwable $previous |
||
| 40 | */ |
||
| 41 | 295 | public function __construct(string $message = '', array $context = [], int $code = 0, Throwable $previous = null) |
|
| 46 | 295 | } |
|
| 47 | |||
| 48 | /** |
||
| 49 | * Gets the exception context |
||
| 50 | * |
||
| 51 | * @return array |
||
| 52 | */ |
||
| 53 | 19 | public function getContext() : array |
|
| 54 | { |
||
| 55 | 19 | return $this->context; |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Gets data from the exception context for the given key |
||
| 60 | * |
||
| 61 | * The default value will be returned if is no data |
||
| 62 | * in the exception context for the given key. |
||
| 63 | * |
||
| 64 | * @param string $key |
||
| 65 | * @param mixed $default |
||
| 66 | * |
||
| 67 | * @return mixed |
||
| 68 | */ |
||
| 69 | 11 | public function fromContext(string $key, $default = null) |
|
| 72 | } |
||
| 73 | } |
||
| 74 |