Total Complexity | 5 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 90.48% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class CumulativeException extends RuntimeException |
||
11 | { |
||
12 | /** @var Throwable[] */ |
||
13 | private array $exceptions; |
||
14 | |||
15 | 1 | public function __construct(Throwable ...$exceptions) |
|
16 | { |
||
17 | 1 | $this->exceptions = $exceptions; |
|
18 | 1 | $count = count($exceptions); |
|
19 | 1 | $message = $count === 1 ? 'One exception was thrown.' : $count . ' exceptions were thrown.'; |
|
20 | 1 | parent::__construct($message . $this->getMessageDetails()); |
|
21 | 1 | } |
|
22 | |||
23 | /** |
||
24 | * @return Throwable[] |
||
25 | */ |
||
26 | public function getExceptions(): array |
||
27 | { |
||
28 | return $this->exceptions; |
||
29 | } |
||
30 | |||
31 | 1 | private function getMessageDetails(): string |
|
47 | } |
||
48 | } |
||
49 |