1 | <?php |
||
18 | class ExceptionCollection extends \Exception implements \IteratorAggregate, \Countable, HttpCacheExceptionInterface |
||
19 | { |
||
20 | private $exceptions = []; |
||
21 | |||
22 | 35 | public function __construct(array $exceptions = []) |
|
23 | { |
||
24 | 35 | foreach ($exceptions as $exception) { |
|
25 | 1 | $this->add($exception); |
|
26 | 35 | } |
|
27 | 35 | } |
|
28 | |||
29 | /** |
||
30 | * Add an exception to the collection. |
||
31 | * |
||
32 | * @param \Exception $e |
||
33 | * |
||
34 | * @return $this |
||
35 | */ |
||
36 | 6 | public function add(\Exception $e) |
|
46 | |||
47 | /** |
||
48 | * Get first exception in collection or null, if there is none. |
||
49 | * |
||
50 | * @return \Exception|null |
||
51 | */ |
||
52 | 5 | public function getFirst() |
|
58 | |||
59 | /** |
||
60 | * Get exception iterator. |
||
61 | * |
||
62 | * @return \ArrayIterator |
||
63 | */ |
||
64 | 3 | public function getIterator() |
|
68 | |||
69 | /** |
||
70 | * Get number of exceptions in collection. |
||
71 | * |
||
72 | * @return int |
||
73 | */ |
||
74 | 34 | public function count() |
|
78 | } |
||
79 |