/** * Add exceptions to the collection * * @param ExceptionCollection|\Exception $e Exception to add * * @return ExceptionCollection; */ public function add($e) { if ($e instanceof self) { foreach ($e as $exception) { $this->exceptions[] = $exception; } } elseif ($e instanceof \Exception) { $this->exceptions[] = $e; } $this->message = implode("\n", array_map(function ($e) { return $e->getMessage(); }, $this->exceptions)); return $this; }
/** * Add exceptions to the collection * * @param ExceptionCollection|\Exception $e Exception to add * * @return ExceptionCollection; */ public function add($e) { if ($this->message) { $this->message .= "\n"; } if ($e instanceof self) { foreach ($e as $exception) { $this->exceptions[] = $exception; $this->message .= $e->getMessage() . "\n"; } } elseif ($e instanceof \Exception) { $this->exceptions[] = $e; $this->message .= $e->getMessage(); } $this->message = rtrim($this->message); return $this; }