Code Duplication    Length = 15-15 lines in 2 locations

src/Service/UsersService.php 1 location

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

src/Service/TasksService.php 1 location

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