@@ -21,21 +21,20 @@ public function __construct(Client $client)
21
21
* This method allows you to create records on your index by sending one or more objects.
22
22
* Each object contains a set of attributes and values, which represents a full record on an index.
23
23
*
24
- * @param array|SearchableEntity $searchableEntities
24
+ * @param array<SearchableEntity> |SearchableEntity $searchableEntities
25
25
*
26
26
* @throws ApiException
27
27
*/
28
28
public function index ($ searchableEntities ): array
29
29
{
30
30
if ($ searchableEntities instanceof SearchableEntity) {
31
- /** @var SearchableEntity[] $searchableEntities */
32
31
$ searchableEntities = [$ searchableEntities ];
33
32
}
34
33
35
34
$ data = [];
36
35
foreach ($ searchableEntities as $ entity ) {
37
36
$ searchableArray = $ entity ->getSearchableArray ();
38
- if (null === $ searchableArray || 0 === \count ( $ searchableArray ) ) {
37
+ if ([] === $ searchableArray ) {
39
38
continue ;
40
39
}
41
40
@@ -62,18 +61,16 @@ public function index($searchableEntities): array
62
61
* Remove objects from an index using their object UIDs.
63
62
* This method enables you to remove one or more objects from an index.
64
63
*
65
- * @param array|SearchableEntity $searchableEntities
64
+ * @param array<SearchableEntity> |SearchableEntity $searchableEntities
66
65
*/
67
66
public function remove ($ searchableEntities ): array
68
67
{
69
68
if ($ searchableEntities instanceof SearchableEntity) {
70
- /** @var SearchableEntity[] $searchableEntities */
71
69
$ searchableEntities = [$ searchableEntities ];
72
70
}
73
71
74
72
$ data = [];
75
73
76
- /** @var SearchableEntity $entity */
77
74
foreach ($ searchableEntities as $ entity ) {
78
75
$ searchableArray = $ entity ->getSearchableArray ();
79
76
if (0 === \count ($ searchableArray )) {
@@ -111,9 +108,8 @@ public function remove($searchableEntities): array
111
108
public function clear (string $ indexUid ): array
112
109
{
113
110
$ index = $ this ->client ->index ($ indexUid );
114
- $ task = $ index ->deleteAllDocuments ();
115
111
116
- return $ task ;
112
+ return $ index -> deleteAllDocuments () ;
117
113
}
118
114
119
115
/**
@@ -129,11 +125,7 @@ public function delete(string $indexUid): ?array
129
125
*/
130
126
public function search (string $ query , string $ indexUid , array $ searchParams ): array
131
127
{
132
- if ('' === $ query ) {
133
- $ query = null ;
134
- }
135
-
136
- return $ this ->client ->index ($ indexUid )->rawSearch ($ query , $ searchParams );
128
+ return $ this ->client ->index ($ indexUid )->rawSearch ('' !== $ query ? $ query : null , $ searchParams );
137
129
}
138
130
139
131
/**
0 commit comments