Completed
Pull Request — master (#85)
by joanhey
01:20
created

pgsql_limit.php ➔ pgsql_limit()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 4
nop 3
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * KumbiaPHP web & app Framework.
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD license that is bundled
8
 * with this package in the file LICENSE.txt.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://wiki.kumbiaphp.com/Licencia
11
 * If you did not receive a copy of the license and are unable to
12
 * obtain it through the world-wide-web, please send an email
13
 * to [email protected] so we can send you a copy immediately.
14
 *
15
 * @category   Kumbia
16
 *
17
 * @copyright  2005 - 2016  Kumbia Team (http://www.kumbiaphp.com)
18
 * @license    http://wiki.kumbiaphp.com/Licencia     New BSD License
19
 */
20
namespace Kumbia\ActiveRecord\Query;
21
22
/**
23
 * Adiciona limit y offset a la consulta sql en pgsql.
24
 *
25
 * @param string $sql    consulta select
26
 * @param string $limit  valor limit
27
 * @param string $offset valor offset
28
 *
29
 * @return string
30
 */
31 View Code Duplication
function pgsql_limit($sql, $limit = null, $offset = null)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
{
33
    if ($limit !== null) {
34
        $limit = (int) $limit;
35
        $sql .= " LIMIT $limit";
36
    }
37
38
    if ($offset !== null) {
39
        $offset = (int) $offset;
40
        $sql .= " OFFSET $offset";
41
    }
42
43
    return $sql;
44
}
45