Conditions | 6 |
Paths | 9 |
Total Lines | 25 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
25 | public static function configure(QueryInterface $query, $config = []): QueryInterface |
||
26 | { |
||
27 | |||
28 | // Halt |
||
29 | if (empty($config)) { |
||
30 | return $query; |
||
31 | } |
||
32 | |||
33 | // Force array |
||
34 | if (!is_array($config)) { |
||
35 | $config = ArrayHelper::toArray($config, [], false); |
||
36 | } |
||
37 | |||
38 | // Populate query attributes |
||
39 | foreach ($config as $name => $value) { |
||
40 | if (property_exists($query, $name)) { |
||
41 | $query->$name = $value; |
||
42 | } elseif (method_exists($query, 'set' . $name)) { |
||
43 | // set property |
||
44 | $query->{'set' . $name}($value); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | return $query; |
||
49 | } |
||
50 | } |
||
51 |