| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | 11 | public function build(ExpressionInterface $expression, array &$params = []): string |
|
| 36 | { |
||
| 37 | /** |
||
| 38 | * @var JsonExpression $expression |
||
| 39 | * @var mixed|QueryInterface $value |
||
| 40 | */ |
||
| 41 | 11 | $value = $expression->getValue(); |
|
| 42 | |||
| 43 | 11 | if ($value instanceof QueryInterface) { |
|
| 44 | 2 | [$sql, $params] = $this->queryBuilder->build($value, $params); |
|
| 45 | |||
| 46 | 2 | return "($sql)"; |
|
| 47 | } |
||
| 48 | |||
| 49 | 9 | $placeholder = self::PARAM_PREFIX . count($params); |
|
| 50 | 9 | $params[$placeholder] = Json::encode($value); |
|
| 51 | |||
| 52 | 9 | return "CAST($placeholder AS JSON)"; |
|
| 53 | } |
||
| 55 |