| Conditions | 3 |
| Paths | 1 |
| Total Lines | 17 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public static function quoteExpression(PDO $pdo, string $expression, array $arguments = []): string { |
||
| 17 | $index = -1; |
||
| 18 | $func = static function () use ($pdo, $arguments, &$index) { |
||
| 19 | $index++; |
||
| 20 | if(array_key_exists($index, $arguments)) { |
||
| 21 | $argument = $arguments[$index]; |
||
| 22 | $value = MySQLValueQuoter::quote($pdo, $argument); |
||
| 23 | } elseif(count($arguments) > 0) { |
||
| 24 | $args = $arguments; |
||
| 25 | $value = array_pop($args); |
||
| 26 | $value = MySQLValueQuoter::quote($pdo, $value); |
||
| 27 | } else { |
||
| 28 | $value = 'NULL'; |
||
| 29 | } |
||
| 30 | return $value; |
||
| 31 | }; |
||
| 32 | return (string) preg_replace_callback('/(\\?)/', $func, $expression); |
||
| 33 | } |
||
| 35 |