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