Completed
Push — master ( 971f99...10707b )
by Peter
07:20 queued 02:39
created

LimitableTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
lcom 2
cbo 0
dl 0
loc 67
ccs 16
cts 16
cp 1
rs 10
c 1
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getLimit() 0 4 1
A getOffset() 0 4 1
A limit() 0 5 1
A offset() 0 5 1
A setLimit() 0 5 1
A setOffset() 0 5 1
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL or Commercial license.
5
 *
6
 * @package maslosoft/mangan
7
 * @licence AGPL or Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]>
9
 * @copyright Copyright (c) Maslosoft
10
 * @copyright Copyright (c) Others as mentioned in code
11
 * @link http://maslosoft.com/mangan/
12
 */
13
14
namespace Maslosoft\Mangan\Traits\Criteria;
15
16
use Maslosoft\Mangan\Interfaces\Criteria\LimitableInterface;
17
use Maslosoft\Mangan\Interfaces\CriteriaInterface;
18
19
/**
20
 * LimitableTrait
21
 * @see LimitableInterface
22
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
23
 */
24
trait LimitableTrait
25
{
26
27
	private $_limit = null;
28
	private $_offset = null;
29
30
	/**
31
	 * Set linit
32
	 * Multiple calls will overrride previous value of limit
33
	 *
34
	 * @param integer $limit limit
35
	 * @return CriteriaInterface
36
	 */
37 1
	public function limit($limit)
38
	{
39 1
		$this->_limit = intval($limit);
40 1
		return $this;
41
	}
42
43
	/**
44
	 * Set offset
45
	 * Multiple calls will override previous value
46
	 *
47
	 * @return CriteriaInterface
48
	 */
49 1
	public function offset($offset)
50
	{
51 1
		$this->_offset = intval($offset);
52 1
		return $this;
53
	}
54
55
	/**
56
	 * @since v1.0
57
	 */
58 51
	public function getLimit()
59
	{
60 51
		return $this->_limit;
61
	}
62
63
	/**
64
65
	 * @return CriteriaInterface
66
	 */
67 1
	public function setLimit($limit)
68
	{
69 1
		$this->limit($limit);
70 1
		return $this;
71
	}
72
73
	/**
74
	 * @return CriteriaInterface
75
	 */
76 51
	public function getOffset()
77
	{
78 51
		return $this->_offset;
79
	}
80
81
	/**
82
	 * @since v1.0
83
	 */
84 1
	public function setOffset($offset)
85
	{
86 1
		$this->offset($offset);
87 1
		return $this;
88
	}
89
90
}
91