Code Duplication    Length = 18-21 lines in 2 locations

src/Service/TasksService.php 1 location

@@ 128-145 (lines=18) @@
125
     * @return array
126
     * @throws \Exception
127
     */
128
    public function updateTask($input, $taskId)
129
    {
130
        $task = $this->checkTask($taskId);
131
        if (empty($input['task']) && empty($input['status'])) {
132
            throw new \Exception(self::TASK_INFO_REQUIRED, 400);
133
        }
134
        $taskname = isset($input['task']) ? $input['task'] : $task->task;
135
        $status = isset($input['status']) ? $input['status'] : $task->status;
136
        $repository = new TasksRepository;
137
        $query = $repository->updateTaskQuery();
138
        $statement = $this->database->prepare($query);
139
        $statement->bindParam('id', $taskId);
140
        $statement->bindParam('task', $taskname);
141
        $statement->bindParam('status', $status);
142
        $statement->execute();
143
144
        return $this->checkTask($taskId);
145
    }
146
147
    /**
148
     * Delete a task.

src/Service/UsersService.php 1 location

@@ 126-146 (lines=21) @@
123
     * @return array
124
     * @throws \Exception
125
     */
126
    public function updateUser($input, $userId)
127
    {
128
        $user = $this->checkUser($userId);
129
        if (empty($input['name']) && empty($input['email'])) {
130
            throw new \Exception(self::USER_INFO_REQUIRED, 400);
131
        }
132
        $username = isset($input['name']) ? $input['name'] : $user->name;
133
        $email = $user->email;
134
        if (isset($input['email'])) {
135
            $email = $this->validateEmail($input['email']);
136
        }
137
        $repository = new UsersRepository;
138
        $query = $repository->updateUserQuery();
139
        $statement = $this->database->prepare($query);
140
        $statement->bindParam('id', $userId);
141
        $statement->bindParam('name', $username);
142
        $statement->bindParam('email', $email);
143
        $statement->execute();
144
145
        return $this->checkUser($userId);
146
    }
147
148
    /**
149
     * Delete a user.