@@ -39,7 +39,10 @@ discard block |
||
39 | 39 | |
40 | 40 | protected function getRange(array $value) : string { |
41 | 41 | |
42 | - $parser = function ($value) { if (is_scalar($value)) return $this->getValue($value); }; |
|
42 | + $parser = function ($value) { if (is_scalar($value)) { |
|
43 | + return $this->getValue($value); |
|
44 | + } |
|
45 | + }; |
|
43 | 46 | |
44 | 47 | return ('(' . implode(', ', array_filter(array_map($parser, $value))) . ')'); |
45 | 48 | } |
@@ -50,21 +53,37 @@ discard block |
||
50 | 53 | |
51 | 54 | protected function getOperatable($value) { |
52 | 55 | |
53 | - if (is_scalar($value)) return ('= ' . $this->getValue($value)); |
|
56 | + if (is_scalar($value)) { |
|
57 | + return ('= ' . $this->getValue($value)); |
|
58 | + } |
|
54 | 59 | |
55 | - if (is_array($value)) return ('IN ' . $this->getRange($value)); |
|
60 | + if (is_array($value)) { |
|
61 | + return ('IN ' . $this->getRange($value)); |
|
62 | + } |
|
56 | 63 | |
57 | - if ($value instanceof Type\Not) return ('NOT ' . $this->getValue($value->get())); |
|
64 | + if ($value instanceof Type\Not) { |
|
65 | + return ('NOT ' . $this->getValue($value->get())); |
|
66 | + } |
|
58 | 67 | |
59 | - if ($value instanceof Type\Like) return ('LIKE ' . $this->getValue($value->get())); |
|
68 | + if ($value instanceof Type\Like) { |
|
69 | + return ('LIKE ' . $this->getValue($value->get())); |
|
70 | + } |
|
60 | 71 | |
61 | - if ($value instanceof Type\LessThan) return ('< ' . $value->get()); |
|
72 | + if ($value instanceof Type\LessThan) { |
|
73 | + return ('< ' . $value->get()); |
|
74 | + } |
|
62 | 75 | |
63 | - if ($value instanceof Type\GreaterThan) return ('> ' . $value->get()); |
|
76 | + if ($value instanceof Type\GreaterThan) { |
|
77 | + return ('> ' . $value->get()); |
|
78 | + } |
|
64 | 79 | |
65 | - if ($value instanceof Type\LessThanOrEqual) return ('<= ' . $value->get()); |
|
80 | + if ($value instanceof Type\LessThanOrEqual) { |
|
81 | + return ('<= ' . $value->get()); |
|
82 | + } |
|
66 | 83 | |
67 | - if ($value instanceof Type\GreaterThanOrEqual) return ('>= ' . $value->get()); |
|
84 | + if ($value instanceof Type\GreaterThanOrEqual) { |
|
85 | + return ('>= ' . $value->get()); |
|
86 | + } |
|
68 | 87 | |
69 | 88 | # ------------------------ |
70 | 89 | |
@@ -86,7 +105,9 @@ discard block |
||
86 | 105 | |
87 | 106 | protected function getString($source = null, string $pattern = '', string $separator = '') : string { |
88 | 107 | |
89 | - if (!is_array($source)) return (is_scalar($source) ? strval($source) : ''); |
|
108 | + if (!is_array($source)) { |
|
109 | + return (is_scalar($source) ? strval($source) : ''); |
|
110 | + } |
|
90 | 111 | |
91 | 112 | $regexs = ['key' => '/\^([a-z]+)/', 'value' => '/\$([a-z]+)/']; $matches = ['key' => [], 'value' => []]; |
92 | 113 | |
@@ -98,7 +119,9 @@ discard block |
||
98 | 119 | |
99 | 120 | # Parse pattern |
100 | 121 | |
101 | - foreach ($regexs as $name => $regex) preg_match($regex, $pattern, $matches[$name]); |
|
122 | + foreach ($regexs as $name => $regex) { |
|
123 | + preg_match($regex, $pattern, $matches[$name]); |
|
124 | + } |
|
102 | 125 | |
103 | 126 | # Process replacements |
104 | 127 | |
@@ -106,9 +129,12 @@ discard block |
||
106 | 129 | |
107 | 130 | $output[$count] = $pattern; $item = &$output[$count++]; |
108 | 131 | |
109 | - foreach ($matches as $name => $match) if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
132 | + foreach ($matches as $name => $match) { |
|
133 | + if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
110 | 134 | |
111 | - try { $replace = [$this, $parsers[$match[1]]]($$name); } catch (\TypeError $e) { $replace = ''; } |
|
135 | + try { $replace = [$this, $parsers[$match[1]]]($$name); |
|
136 | + } |
|
137 | + } catch (\TypeError $e) { $replace = ''; } |
|
112 | 138 | |
113 | 139 | $item = str_replace($match[0], $replace, $item); |
114 | 140 | } |