/** * @param mixed $id * @param DomainEventStream $eventStream */ public function append($id, DomainEventStream $eventStream) { $id = (string) $id; //Used to thrown errors if ID will not cast to string $this->db->beginTransaction(); try { foreach ($eventStream as $domainMessage) { $this->insertEvent($domainMessage); } $this->db->commit(); } catch (QueryException $ex) { $this->db->rollBack(); throw $ex; } }