1<?php
2
3/*
4 * This file is part of the Prophecy.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6 *     Marcello Duarte <marcello.duarte@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Prophecy\Exception\Prediction;
13
14use Prophecy\Prophecy\ObjectProphecy;
15
16class AggregateException extends \RuntimeException implements PredictionException
17{
18    private $exceptions = array();
19    private $objectProphecy;
20
21    public function append(PredictionException $exception)
22    {
23        $message = $exception->getMessage();
24        $message = strtr($message, array("\n" => "\n  "))."\n";
25        $message = empty($this->exceptions) ? $message : "\n" . $message;
26
27        $this->message      = rtrim($this->message.$message);
28        $this->exceptions[] = $exception;
29    }
30
31    /**
32     * @return PredictionException[]
33     */
34    public function getExceptions()
35    {
36        return $this->exceptions;
37    }
38
39    public function setObjectProphecy(ObjectProphecy $objectProphecy)
40    {
41        $this->objectProphecy = $objectProphecy;
42    }
43
44    /**
45     * @return ObjectProphecy
46     */
47    public function getObjectProphecy()
48    {
49        return $this->objectProphecy;
50    }
51}
52