Conditions | 2 |
Paths | 2 |
Total Lines | 20 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | * @link http://dev.mysql.com/doc/refman/5.0/en/select.html#id4651990 |
||
23 | */ |
||
24 | View Code Duplication | protected function compileLimit(int $limit, int $offset): string |
|
|
|||
25 | { |
||
26 | if (empty($limit) && empty($offset)) { |
||
27 | return ''; |
||
28 | } |
||
29 | |||
30 | $statement = ''; |
||
31 | if (!empty($limit) || !empty($offset)) { |
||
32 | //When limit is not provided but offset does we can replace limit value with PHP_INT_MAX |
||
33 | $statement = 'LIMIT ' . ($limit ?: '18446744073709551615') . ' '; |
||
34 | } |
||
35 | |||
36 | if (!empty($offset)) { |
||
37 | $statement .= "OFFSET {$offset}"; |
||
38 | } |
||
39 | |||
40 | return trim($statement); |
||
41 | } |
||
42 | |||
70 |
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.