Conditions | 3 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3.0123 |
Changes | 0 |
1 | <?php |
||
24 | 2 | static function parseParameters(string $query, $replaceParams = '?', string $regex = '/(:[a-z]+)|\?|\$\d+/i'): array { |
|
25 | 2 | $params = array(); |
|
26 | 2 | $position = 1; |
|
27 | |||
28 | $query = \preg_replace_callback($regex, function (array $match) use ($replaceParams, &$params, &$position) { |
||
29 | 2 | $params[($position++)] = $match[0]; |
|
30 | |||
31 | 2 | if($replaceParams !== null) { |
|
32 | 2 | return (\is_callable($replaceParams) ? $replaceParams() : $replaceParams); |
|
33 | } |
||
34 | |||
35 | return $match[0]; |
||
36 | 2 | }, $query); |
|
37 | |||
38 | 2 | return array('query' => $query, 'parameters' => $params); |
|
39 | } |
||
41 |