| Conditions | 9 |
| Paths | 12 |
| Total Lines | 22 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 38 | protected function buildLimit(string $query, ?int $offset = null) { |
||
| 39 | $limit = $this->getLimit(); |
||
| 40 | if($limit === null && $offset !== null) { |
||
| 41 | $limit = '18446744073709551615'; |
||
| 42 | } |
||
| 43 | if($this->limit instanceof OptionalValue) { |
||
| 44 | if($this->limit->isValid()) { |
||
| 45 | $value = $this->limit->getValue(); |
||
| 46 | if($value === null || is_scalar($value)) { |
||
| 47 | $value = (string) $value; |
||
| 48 | } else { |
||
| 49 | throw new InvalidValueException('Value for OFFSET has to be a number'); |
||
| 50 | } |
||
| 51 | if(!preg_match('{^\\d+$}', $value)) { |
||
| 52 | throw new InvalidValueException('Value for OFFSET has to be a number'); |
||
| 53 | } |
||
| 54 | $query .= "LIMIT\n\t{$value}\n"; |
||
| 55 | } |
||
| 56 | } elseif($limit !== null) { |
||
| 57 | $query .= "LIMIT\n\t{$limit}\n"; |
||
| 58 | } |
||
| 59 | return $query; |
||
| 60 | } |
||
| 62 |