| @@ 30-43 (lines=14) @@ | ||
| 27 | * @return object $task |
|
| 28 | * @throws \Exception |
|
| 29 | */ |
|
| 30 | public function checkTask($taskId) |
|
| 31 | { |
|
| 32 | $tasksRepository = new TasksRepository; |
|
| 33 | $query = $tasksRepository->getTaskQuery(); |
|
| 34 | $statement = $this->database->prepare($query); |
|
| 35 | $statement->bindParam('id', $taskId); |
|
| 36 | $statement->execute(); |
|
| 37 | $task = $statement->fetchObject(); |
|
| 38 | if (!$task) { |
|
| 39 | throw new \Exception(self::TASK_NOT_FOUND, 404); |
|
| 40 | } |
|
| 41 | ||
| 42 | return $task; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Get all tasks. |
|
| @@ 31-43 (lines=13) @@ | ||
| 28 | * @return object $user |
|
| 29 | * @throws \Exception |
|
| 30 | */ |
|
| 31 | public function checkUser($userId) |
|
| 32 | { |
|
| 33 | $repo = new UsersRepository; |
|
| 34 | $stmt = $this->database->prepare($repo->getUserQuery()); |
|
| 35 | $stmt->bindParam('id', $userId); |
|
| 36 | $stmt->execute(); |
|
| 37 | $user = $stmt->fetchObject(); |
|
| 38 | if (!$user) { |
|
| 39 | throw new \Exception(self::USER_NOT_FOUND, 404); |
|
| 40 | } |
|
| 41 | ||
| 42 | return $user; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Get all users. |
|