File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Ensi \LaravelElasticQuery \Contracts ;
4+
5+ use stdClass ;
6+
7+ class DSL
8+ {
9+ public static function filter (array $ dsl ): array |stdClass
10+ {
11+ return array_filter ($ dsl , fn (mixed $ item ) => !is_null ($ item )) ?: new stdClass ;
12+ }
13+ }
Original file line number Diff line number Diff line change 22
33namespace Ensi \LaravelElasticQuery \Search \Highlight ;
44
5+ use Ensi \LaravelElasticQuery \Contracts \DSL ;
56use Ensi \LaravelElasticQuery \Contracts \DSLAware ;
67use Ensi \LaravelElasticQuery \Filtering \BoolQueryBuilder ;
78use Ensi \LaravelElasticQuery \Search \Enums \BoundaryScanner ;
@@ -60,7 +61,7 @@ public function __construct(
6061
6162 public function toDSL (): array |stdClass
6263 {
63- $ dsl = array_filter ([
64+ return DSL :: filter ( array_filter ([
6465 'boundary_chars ' => $ this ->boundaryChars ,
6566 'boundary_max_scan ' => $ this ->boundaryMaxScan ,
6667 'boundary_scanner ' => $ this ->boundaryScanner ,
@@ -90,12 +91,6 @@ public function toDSL(): array|stdClass
9091 'max_analyzed_offset ' => $ this ->maxAnalyzedOffset ,
9192 'tags_schema ' => $ this ->tagsSchema ,
9293 'type ' => $ this ->type ,
93- ], fn (mixed $ item ) => !is_null ($ item ));
94-
95- if (!$ dsl ) {
96- return new stdClass ();
97- }
98-
99- return $ dsl ;
94+ ]));
10095 }
10196}
You can’t perform that action at this time.
0 commit comments