AbstractCriteria   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 125
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 13
c 0
b 0
f 0
lcom 3
cbo 0
dl 0
loc 125
ccs 33
cts 33
cp 1
rs 10

13 Methods

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