1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of ContextException |
||
5 | * (c) Fabrice de Stefanis / https://github.com/fab2s/ContextException |
||
6 | * This source file is licensed under the MIT license which you will |
||
7 | * find in the LICENSE file or at https://opensource.org/licenses/MIT |
||
8 | */ |
||
9 | |||
10 | namespace fab2s\ContextException; |
||
11 | |||
12 | /** |
||
13 | * Trait ContextException |
||
14 | */ |
||
15 | trait ContextExceptionTrait |
||
16 | { |
||
17 | /** |
||
18 | * Exception context |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $context = []; |
||
23 | |||
24 | /** |
||
25 | * Get current exception context, useful for logging |
||
26 | * |
||
27 | * @return array |
||
28 | */ |
||
29 | public function getContext(): array |
||
30 | { |
||
31 | return $this->context; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param array $context |
||
36 | * |
||
37 | * @return static |
||
38 | */ |
||
39 | public function setContext(array $context): ContextExceptionInterface |
||
40 | { |
||
41 | $this->context = $context; |
||
42 | |||
43 | return $this; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
44 | } |
||
45 | } |
||
46 |