@@ -191,10 +191,10 @@ |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | - * |
|
| 195 | - * @param array $currentParams |
|
| 196 | - * @return \leandrogehlen\querybuilder\Translator |
|
| 197 | - */ |
|
| 194 | + * |
|
| 195 | + * @param array $currentParams |
|
| 196 | + * @return \leandrogehlen\querybuilder\Translator |
|
| 197 | + */ |
|
| 198 | 198 | public function setCurrentParams($currentParams) { |
| 199 | 199 | $this->currentParams = $currentParams; |
| 200 | 200 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function __construct($data, $config = []) |
| 53 | 53 | { |
| 54 | - if(isset($config['currentParams'])){ |
|
| 54 | + if (isset($config['currentParams'])) { |
|
| 55 | 55 | $this->setCurrentParams($config['currentParams']); |
| 56 | 56 | |
| 57 | 57 | } |
@@ -67,19 +67,19 @@ discard block |
||
| 67 | 67 | $this->_operators = [ |
| 68 | 68 | 'equal' => '= ?', |
| 69 | 69 | 'not_equal' => '<> ?', |
| 70 | - 'in' => ['op' => 'IN (?)', 'list' => true, 'sep' => ', ' ], |
|
| 70 | + 'in' => ['op' => 'IN (?)', 'list' => true, 'sep' => ', '], |
|
| 71 | 71 | 'not_in' => ['op' => 'NOT IN (?)', 'list' => true, 'sep' => ', '], |
| 72 | 72 | 'less' => '< ?', |
| 73 | 73 | 'less_or_equal' => '<= ?', |
| 74 | 74 | 'greater' => '> ?', |
| 75 | 75 | 'greater_or_equal' => '>= ?', |
| 76 | - 'between' => ['op' => 'BETWEEN ?', 'list' => true, 'sep' => ' AND '], |
|
| 77 | - 'begins_with' => ['op' => 'LIKE ?', 'fn' => function($value){ return "$value%"; } ], |
|
| 78 | - 'not_begins_with' => ['op' => 'NOT LIKE ?', 'fn' => function($value){ return "$value%"; } ], |
|
| 79 | - 'contains' => ['op' => 'LIKE ?', 'fn' => function($value){ return "%$value%"; } ], |
|
| 80 | - 'not_contains' => ['op' => 'NOT LIKE ?', 'fn' => function($value){ return "%$value%"; } ], |
|
| 81 | - 'ends_with' => ['op' => 'LIKE ?', 'fn' => function($value){ return "%$value"; } ], |
|
| 82 | - 'not_ends_with' => ['op' => 'NOT LIKE ?', 'fn' => function($value){ return "%$value"; } ], |
|
| 76 | + 'between' => ['op' => 'BETWEEN ?', 'list' => true, 'sep' => ' AND '], |
|
| 77 | + 'begins_with' => ['op' => 'LIKE ?', 'fn' => function($value) { return "$value%"; }], |
|
| 78 | + 'not_begins_with' => ['op' => 'NOT LIKE ?', 'fn' => function($value) { return "$value%"; }], |
|
| 79 | + 'contains' => ['op' => 'LIKE ?', 'fn' => function($value) { return "%$value%"; }], |
|
| 80 | + 'not_contains' => ['op' => 'NOT LIKE ?', 'fn' => function($value) { return "%$value%"; }], |
|
| 81 | + 'ends_with' => ['op' => 'LIKE ?', 'fn' => function($value) { return "%$value"; }], |
|
| 82 | + 'not_ends_with' => ['op' => 'NOT LIKE ?', 'fn' => function($value) { return "%$value"; }], |
|
| 83 | 83 | 'is_empty' => '= ""', |
| 84 | 84 | 'is_not_empty' => '<> ""', |
| 85 | 85 | 'is_null' => 'IS NULL', |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } else { |
| 106 | 106 | $op = ArrayHelper::getValue($pattern, 'op'); |
| 107 | 107 | $list = ArrayHelper::getValue($pattern, 'list'); |
| 108 | - if ($list){ |
|
| 108 | + if ($list) { |
|
| 109 | 109 | $sep = ArrayHelper::getValue($pattern, 'sep'); |
| 110 | 110 | $replacement = implode($sep, $keys); |
| 111 | 111 | } else { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $this->_params = array_merge($this->_params, $params); |
| 120 | - return $field . " " . ($replacement ? str_replace("?", $replacement, $pattern) : $pattern); |
|
| 120 | + return $field." ".($replacement ? str_replace("?", $replacement, $pattern) : $pattern); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $where = []; |
| 134 | - $condition = " " . $data['condition'] . " "; |
|
| 134 | + $condition = " ".$data['condition']." "; |
|
| 135 | 135 | |
| 136 | 136 | foreach ($data['rules'] as $rule) { |
| 137 | 137 | if (isset($rule['condition'])) { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $where[] = $this->encodeRule($field, $operator, $params); |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | - return "(" . implode($condition, $where) . ")"; |
|
| 158 | + return "(".implode($condition, $where).")"; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | * Get a param name that should not conflict with any params already set |
| 181 | 181 | * @return string |
| 182 | 182 | */ |
| 183 | - private function getNewParamName(){ |
|
| 183 | + private function getNewParamName() { |
|
| 184 | 184 | $paramPrefix = 'p'; |
| 185 | - if(!empty($this->currentParams) && $this->paramsCount < count($this->currentParams) ){ |
|
| 186 | - $this->paramsCount = count($this->currentParams) +1; |
|
| 187 | - }else{ |
|
| 185 | + if (!empty($this->currentParams) && $this->paramsCount < count($this->currentParams)) { |
|
| 186 | + $this->paramsCount = count($this->currentParams) + 1; |
|
| 187 | + } else { |
|
| 188 | 188 | $this->paramsCount = $this->paramsCount + 1; |
| 189 | 189 | } |
| 190 | 190 | return $paramPrefix.$this->paramsCount; |
@@ -184,7 +184,7 @@ |
||
| 184 | 184 | $paramPrefix = 'p'; |
| 185 | 185 | if(!empty($this->currentParams) && $this->paramsCount < count($this->currentParams) ){ |
| 186 | 186 | $this->paramsCount = count($this->currentParams) +1; |
| 187 | - }else{ |
|
| 187 | + } else{ |
|
| 188 | 188 | $this->paramsCount = $this->paramsCount + 1; |
| 189 | 189 | } |
| 190 | 190 | return $paramPrefix.$this->paramsCount; |