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