1 | <?php |
||
18 | class ExceptionCollection extends \Exception implements \IteratorAggregate, \Countable, HttpCacheExceptionInterface |
||
19 | { |
||
20 | private $exceptions = []; |
||
21 | |||
22 | 40 | public function __construct(array $exceptions = []) |
|
23 | { |
||
24 | 40 | foreach ($exceptions as $exception) { |
|
25 | $this->add($exception); |
||
26 | 40 | } |
|
27 | 40 | } |
|
28 | |||
29 | /** |
||
30 | * Add an exception to the collection |
||
31 | * |
||
32 | * @param \Exception $e |
||
33 | * |
||
34 | * @return $this |
||
35 | */ |
||
36 | 3 | 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 | 2 | public function getFirst() |
|
60 | |||
61 | /** |
||
62 | * Get exception iterator |
||
63 | * |
||
64 | * @return \ArrayIterator |
||
65 | */ |
||
66 | 2 | public function getIterator() |
|
70 | |||
71 | /** |
||
72 | * Get number of exceptions in collection |
||
73 | * |
||
74 | * @return int |
||
75 | */ |
||
76 | 39 | public function count() |
|
80 | } |
||
81 |