AbstractSQL::limit()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * Query
4
 *
5
 * SQL Query Builder / Database Abstraction Layer
6
 *
7
 * PHP version 7.1
8
 *
9
 * @package     Query
10
 * @author      Timothy J. Warren <[email protected]>
11
 * @copyright   2012 - 2018 Timothy J. Warren
12
 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
 * @link        https://git.timshomepage.net/aviat4ion/Query
14
 */
15
namespace Query\Drivers;
16
17
/**
18
 * Parent for database-specific syntax subclasses
19
 */
20
abstract class AbstractSQL implements SQLInterface {
21
22
	/**
23
	 * Limit clause
24
	 *
25
	 * @param string $sql
26
	 * @param int $limit
27
	 * @param int|bool $offset
28
	 * @return string
29
	 */
30
	public function limit(string $sql, int $limit, $offset=FALSE): string
31
	{
32
		$sql .= "\nLIMIT {$limit}";
33
34
		if (is_numeric($offset))
35
		{
36
			$sql .= " OFFSET {$offset}";
37
		}
38
39
		return $sql;
40
	}
41
}
42