/** * resolves user id to user data. * * @param int $id id to resolve * * @return User */ public function resolveUserFunction($id) { if ($this->cache->contains($id)) { return $this->cache->fetch($id); } $user = $this->userRepository->findUserById($id); if ($user === null) { return; } $this->cache->save($id, $user); return $user; }
/** * resolves user id to user data. * * @param int $userId id to resolve * * @return Contact */ public function resolveUserFunction($userId) { if (!$this->cache->contains($userId)) { $user = $this->userRepository->findUserById($userId); if ($user === null) { return; } $this->cache->save($userId, $user->getContact()); } return $this->cache->fetch($userId); }