/** * @param string $id * * @return ReadModelInterface * @throws ReadModelNotFound */ public function find(string $id) : ReadModelInterface { if (isset($this->data[$id])) { return $this->data[$id]; } throw ReadModelNotFound::with($id); }
/** * @param string $id * * @return ReadModelInterface * @throws ReadModelNotFound */ public function find(string $id) : ReadModelInterface { /** @var \stdClass|null $row */ $row = $this->connection->table($this->table)->where($this->primaryKey, $id)->first(); if (is_null($row)) { throw ReadModelNotFound::with($id); } return $this->deserialize($row); }