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