Completed
Push — master ( 609278...8dc5cd )
by Mauro
02:19
created

TaskRepository::getTasks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace App\Repository;
4
5
/**
6
 * Tasks Repository.
7
 */
8
class TaskRepository extends BaseRepository
9
{
10
    /**
11
     * @param object $database
12
     */
13
    public function __construct(\PDO $database = null)
14
    {
15
        $this->database = $database;
16
    }
17
18
    /**
19
     * Get all tasks.
20
     *
21
     * @return array
22
     */
23
    public function getTasks()
24
    {
25
        $query = $this->getTasksQuery();
26
        $statement = $this->database->prepare($query);
27
        $statement->execute();
28
29
        return $statement->fetchAll();
30
    }
31
32
    /**
33
     * Get Task Sql Query.
34
     *
35
     * @return string
36
     */
37
    public function getTaskQuery()
38
    {
39
        return 'SELECT * FROM tasks WHERE id=:id';
40
    }
41
42
    public function getTasksQuery()
43
    {
44
        return 'SELECT * FROM tasks ORDER BY task';
45
    }
46
47
    public function searchTasksQuery()
48
    {
49
        return 'SELECT * FROM tasks WHERE UPPER(task) LIKE :query ORDER BY task';
50
    }
51
52
    public function createTaskQuery()
53
    {
54
        return 'INSERT INTO tasks (task, status) VALUES (:task, :status)';
55
    }
56
57
    public function updateTaskQuery()
58
    {
59
        return 'UPDATE tasks SET task=:task, status=:status WHERE id=:id';
60
    }
61
62
    public function deleteTaskQuery()
63
    {
64
        return 'DELETE FROM tasks WHERE id=:id';
65
    }
66
}
67