Code Duplication    Length = 14-15 lines in 2 locations

src/Service/TaskService.php 1 location

@@ 81-95 (lines=15) @@
78
     * @return array
79
     * @throws \Exception
80
     */
81
    public function searchTasks($tasksName)
82
    {
83
        $repository = new TaskRepository;
84
        $query = $repository->searchTasksQuery();
85
        $statement = $this->database->prepare($query);
86
        $query = '%' . $tasksName . '%';
87
        $statement->bindParam('query', $query);
88
        $statement->execute();
89
        $tasks = $statement->fetchAll();
90
        if (!$tasks) {
91
            throw new \Exception(MessageService::TASK_NOT_FOUND, 404);
92
        }
93
94
        return $tasks;
95
    }
96
97
    /**
98
     * Create a task.

src/Service/UserService.php 1 location

@@ 80-93 (lines=14) @@
77
     * @return array
78
     * @throws \Exception
79
     */
80
    public function searchUsers($str)
81
    {
82
        $repo = new UserRepository;
83
        $stmt = $this->database->prepare($repo->searchUsersQuery());
84
        $name = '%' . $str . '%';
85
        $stmt->bindParam('name', $name);
86
        $stmt->execute();
87
        $users = $stmt->fetchAll();
88
        if (!$users) {
89
            throw new \Exception(MessageService::USER_NAME_NOT_FOUND, 404);
90
        }
91
92
        return $users;
93
    }
94
95
    /**
96
     * Create a user.