Completed
Push — master ( 67808b...30814e )
by Derek Stephen
02:02
created

Criteria::hasOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Del\Common;
4
5
6
class Criteria
7
{
8
    protected $limit;
9
    protected $offset;
10
    protected $order;
11
    protected $orderDirection;
12
13
    /**
14
     * @return bool
15
     */
16 2
    public function hasOffset()
17
    {
18 2
        return $this->offset !== null;
19
    }
20
21
    /**
22
     * @param $code
23
     * @return $this
24
     */
25 2
    public function setOffset($code)
26
    {
27 2
        $this->offset = $code;
28 2
        return $this;
29
    }
30
31
    /**
32
     * @return mixed
33
     */
34 2
    public function getOffset()
35
    {
36 2
        return $this->offset;
37
    }
38
39
    /**
40
     * @return bool
41
     */
42 2
    public function hasLimit()
43
    {
44 2
        return $this->limit !== null;
45
    }
46
47
    /**
48
     * @param $code
49
     * @return $this
50
     */
51 2
    public function setLimit($code)
52
    {
53 2
        $this->limit = $code;
54 2
        return $this;
55
    }
56
57
    /**
58
     * @return mixed
59
     */
60 2
    public function getLimit()
61
    {
62 2
        return $this->limit;
63
    }
64
65
    /**
66
     * @return bool
67
     */
68 1
    public function hasOrder()
69
    {
70 1
        return $this->order !== null;
71
    }
72
73
    /**
74
     * @param $code
75
     * @return $this
76
     */
77 1
    public function setOrder($order)
78
    {
79 1
        $this->order = $order;
80 1
        return $this;
81
    }
82
83
    /**
84
     * @return mixed
85
     */
86 1
    public function getOrder()
87
    {
88 1
        return $this->order;
89
    }
90
91
    /**
92
     * @return mixed
93
     */
94 1
    public function getOrderDirection()
95
    {
96 1
        return $this->orderDirection;
97
    }
98
99
    /**
100
     * @param mixed $orderDirection
101
     * @return Criteria
102
     */
103 1
    public function setOrderDirection($orderDirection)
104
    {
105 1
        $this->orderDirection = $orderDirection;
106 1
        return $this;
107
    }
108
109
    /**
110
     * @return bool
111
     */
112 1
    public function hasOrderDirection()
113
    {
114 1
        return $this->orderDirection !== null;
115
    }
116
117
    /**
118
     * @param $page
119
     * @param $limit
120
     */
121 1
    public function setPagination($page, $limit)
122
    {
123 1
        $offset = ($limit * $page) - $limit;
124 1
        $this->setLimit($limit);
125 1
        $this->setOffset($offset);
126
    }
127
}