1616 */
1717class CriteriaItem extends CriteriaElement
1818{
19-
2019 protected ?string $ prefix = null ;
2120 protected ?string $ function = null ;
2221 protected null |string |int $ column = null ;
@@ -39,19 +38,18 @@ class CriteriaItem extends CriteriaElement
3938 * @param string|null $function
4039 */
4140 public function __construct (
42- string |int $ column ,
43- mixed $ value = null ,
41+ string |int $ column ,
42+ mixed $ value = null ,
4443 ComparisonOperator |string $ operator = '= ' ,
45- ?string $ prefix = null ,
46- ?string $ function = null
47- )
48- {
44+ ?string $ prefix = null ,
45+ ?string $ function = null
46+ ) {
4947 parent ::__construct ();
5048
5149 $ this ->prefix = $ prefix ;
5250 $ this ->function = $ function ;
5351 $ this ->column = $ column ;
54- $ this ->operator = $ operator instanceof ComparisonOperator ? $ operator : ComparisonOperator:: from ( strtoupper ( trim ( $ operator)) );
52+ $ this ->operator = ComparisonOperator:: resolve ( $ operator );
5553
5654 if (is_string ($ value ) && str_starts_with ($ value , '( ' )) {
5755 $ this ->data [] = $ value ;
@@ -140,9 +138,17 @@ public function render(bool $withBindVariables = false): ?string
140138 break ;
141139 default :
142140 if ($ withBindVariables ) {
143- $ clause .= sprintf (" %s %s " , $ this ->operator ->value , $ this ->prepareRenderedValue (current ($ this ->data )));
141+ $ clause .= sprintf (
142+ " %s %s " ,
143+ $ this ->operator ->value ,
144+ $ this ->prepareRenderedValue (current ($ this ->data ))
145+ );
144146 } else {
145- $ clause .= sprintf (" %s :%s " , $ this ->operator ->value , key ($ this ->data ));
147+ $ clause .= sprintf (
148+ " %s :%s " ,
149+ $ this ->operator ->value ,
150+ key ($ this ->data )
151+ );
146152 }
147153 }
148154
@@ -172,7 +178,7 @@ protected function prepareRenderedValue(null|bool|object|string|float|array $val
172178 }
173179
174180 if (is_object ($ value )) {
175- if (( interface_exists (Stringable::class) && ( $ value instanceof Stringable)) || method_exists ( $ value , ' __toString ' ) ) {
181+ if ($ value instanceof Stringable) {
176182 return $ this ->addSlashes ((string )$ value );
177183 }
178184
@@ -234,4 +240,4 @@ public function __toString(): string
234240 {
235241 return $ this ->render ();
236242 }
237- }
243+ }
0 commit comments