| Conditions | 3 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | protected function compile(string $statement): string |
||
| 22 | { |
||
| 23 | $wrappedPath = $this->getWrappedPath($statement); |
||
| 24 | $attribute = \array_pop($wrappedPath); |
||
| 25 | $path = $this->getField($statement); |
||
| 26 | if ($wrappedPath !== []) { |
||
| 27 | $path .= '->' . \implode('->', $wrappedPath); |
||
| 28 | } |
||
| 29 | |||
| 30 | if (!\filter_var($attribute, FILTER_VALIDATE_INT)) { |
||
| 31 | return \sprintf('coalesce((%s)::jsonb ?? %s, false)', $path, $attribute); |
||
| 32 | } |
||
| 33 | |||
| 34 | return \vsprintf('CASE WHEN %s THEN %s ELSE false END', [ |
||
| 35 | \sprintf('jsonb_typeof((%s)::jsonb) = \'array\'', $path), |
||
| 36 | \sprintf('jsonb_array_length((%s)::jsonb) >= %s', $path, $attribute + 1), |
||
| 37 | ]); |
||
| 40 |