Completed
Push — master ( 9ef975...f27292 )
by Ron
02:46
created

LimitBuilder::getLimit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Kir\MySQL\Builder\Traits;
3
4
trait LimitBuilder {
5
	/** @var int */
6
	private $limit = null;
7
8
	/**
9
	 * @return int
10
	 */
11
	protected function getLimit() {
12
		return $this->limit;
13
	}
14
15
	/**
16
	 * @param int $limit
17
	 * @return $this
18
	 */
19
	public function limit($limit) {
20
		$this->limit = $limit;
21
		return $this;
22
	}
23
24
	/**
25
	 * @param string $query
26
	 * @param null $offset
27
	 * @return string
28
	 */
29
	protected function buildLimit($query, $offset = null) {
30
		$limit = $this->limit;
31
		if($limit === null && $offset !== null) {
32
			$limit = '18446744073709551615';
33
		}
34
		if($limit !== null) {
35
			$query .= "LIMIT\n\t{$limit}\n";
36
		}
37
		return $query;
38
	}
39
}
40