Code Duplication    Length = 15-15 lines in 2 locations

src/Service/TasksService.php 1 location

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

src/Service/UsersService.php 1 location

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