77
88class Builder implements BuilderInterface
99{
10- const GEO_FILTER_UNITS = ['m ' , 'km ' , 'mi ' , 'ft ' ];
10+ public const GEO_FILTER_UNITS = ['m ' , 'km ' , 'mi ' , 'ft ' ];
1111
1212 protected $ return = '' ;
1313 protected $ summarize = '' ;
@@ -181,6 +181,11 @@ public function language(string $languageName): BuilderInterface
181181 return $ this ;
182182 }
183183
184+ protected function explodeArgument (?string $ argument ): array
185+ {
186+ return explode (' ' , $ argument ?? '' );
187+ }
188+
184189 public function makeSearchCommandArguments (string $ query ): array
185190 {
186191 $ queryParts = array_merge ([$ query ], $ this ->tagFilters , $ this ->numericFilters , $ this ->geoFilters );
@@ -189,25 +194,25 @@ public function makeSearchCommandArguments(string $query): array
189194 return array_filter (
190195 array_merge (
191196 trim ($ queryWithFilters ) === '' ? [$ this ->indexName ] : [$ this ->indexName , $ queryWithFilters ],
192- explode ( ' ' , $ this ->limit ),
193- explode ( ' ' , $ this ->slop ),
197+ $ this -> explodeArgument ( $ this ->limit ),
198+ $ this -> explodeArgument ( $ this ->slop ),
194199 [
195200 $ this ->verbatim ,
196201 $ this ->withScores ,
197202 $ this ->withPayloads ,
198203 $ this ->noStopWords ,
199204 $ this ->noContent ,
200205 ],
201- explode ( ' ' , $ this ->inFields ),
202- explode ( ' ' , $ this ->inKeys ),
203- explode ( ' ' , $ this ->return ),
204- explode ( ' ' , $ this ->summarize ),
205- explode ( ' ' , $ this ->highlight ),
206- explode ( ' ' , $ this ->sortBy ),
207- explode ( ' ' , $ this ->scorer ),
208- explode ( ' ' , $ this ->language ),
209- explode ( ' ' , $ this ->expander ),
210- explode ( ' ' , $ this ->payload )
206+ $ this -> explodeArgument ( $ this ->inFields ),
207+ $ this -> explodeArgument ( $ this ->inKeys ),
208+ $ this -> explodeArgument ( $ this ->return ),
209+ $ this -> explodeArgument ( $ this ->summarize ),
210+ $ this -> explodeArgument ( $ this ->highlight ),
211+ $ this -> explodeArgument ( $ this ->sortBy ),
212+ $ this -> explodeArgument ( $ this ->scorer ),
213+ $ this -> explodeArgument ( $ this ->language ),
214+ $ this -> explodeArgument ( $ this ->expander ),
215+ $ this -> explodeArgument ( $ this ->payload ),
211216 ),
212217 function ($ item ) {
213218 return !is_null ($ item ) && $ item !== '' ;
0 commit comments