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

LimitBuilder   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 6
c 3
b 0
f 1
lcom 1
cbo 0
dl 0
loc 36
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getLimit() 0 3 1
A limit() 0 4 1
A buildLimit() 0 10 4
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