public function getMapper() { if (!$this->mapper) { throw new InvalidStateException('Repository does not have injected any mapper.'); } return $this->mapper; }