Total Complexity | 4 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 7 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
15 | trait ProxyTrait |
||
16 | { |
||
17 | /** |
||
18 | * @var Throwable|null A throwable object extracted from exception thrown during the last proxy method call. It's |
||
19 | * `null` when no exception was thrown. Automatically reset during the new call. |
||
20 | */ |
||
21 | private ?Throwable $currentError = null; |
||
22 | |||
23 | /** |
||
24 | * Gets current error. |
||
25 | * |
||
26 | * @return Throwable|null {@see $currentError}. |
||
27 | */ |
||
28 | 2 | public function getCurrentError(): ?Throwable |
|
29 | { |
||
30 | 2 | return $this->currentError; |
|
31 | } |
||
32 | |||
33 | /** |
||
34 | * Whether a proxy has current error. |
||
35 | * |
||
36 | * @return bool `true` if it has current error and `false` otherwise. |
||
37 | */ |
||
38 | 2 | public function hasCurrentError(): bool |
|
39 | { |
||
40 | 2 | return $this->currentError !== null; |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Throws current error again. |
||
45 | * |
||
46 | * @param Throwable $error A throwable object. |
||
47 | * |
||
48 | * @throws Throwable An exact error previously stored in {@see $currentError}. |
||
49 | */ |
||
50 | 3 | protected function repeatError(Throwable $error): void |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * Resets current error. |
||
58 | */ |
||
59 | 9 | protected function resetCurrentError(): void |
|
64 |