Skip to content

Commit

Permalink
Fix phpdoc typehint
Browse files Browse the repository at this point in the history
  • Loading branch information
norkunas committed Oct 4, 2024
1 parent a6ee705 commit 5cc52b7
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ public function __construct(Client $client)
* This method allows you to create records on your index by sending one or more objects.
* Each object contains a set of attributes and values, which represents a full record on an index.
*
* @param array|SearchableEntity $searchableEntities
* @param array<SearchableEntity>|SearchableEntity $searchableEntities
*
* @throws ApiException
*/
public function index($searchableEntities): array
{
if ($searchableEntities instanceof SearchableEntity) {
/** @var SearchableEntity[] $searchableEntities */
$searchableEntities = [$searchableEntities];
}

Expand Down Expand Up @@ -62,18 +61,16 @@ public function index($searchableEntities): array
* Remove objects from an index using their object UIDs.
* This method enables you to remove one or more objects from an index.
*
* @param array|SearchableEntity $searchableEntities
* @param array<SearchableEntity>|SearchableEntity $searchableEntities
*/
public function remove($searchableEntities): array
{
if ($searchableEntities instanceof SearchableEntity) {
/** @var SearchableEntity[] $searchableEntities */
$searchableEntities = [$searchableEntities];
}

$data = [];

/** @var SearchableEntity $entity */
foreach ($searchableEntities as $entity) {
$searchableArray = $entity->getSearchableArray();
if (0 === \count($searchableArray)) {
Expand Down Expand Up @@ -111,9 +108,8 @@ public function remove($searchableEntities): array
public function clear(string $indexUid): array
{
$index = $this->client->index($indexUid);
$task = $index->deleteAllDocuments();

return $task;
return $index->deleteAllDocuments();
}

/**
Expand All @@ -129,11 +125,7 @@ public function delete(string $indexUid): ?array
*/
public function search(string $query, string $indexUid, array $searchParams): array
{
if ('' === $query) {
$query = null;
}

return $this->client->index($indexUid)->rawSearch($query, $searchParams);
return $this->client->index($indexUid)->rawSearch($query !== '' ? $query : null, $searchParams);
}

/**
Expand Down

0 comments on commit 5cc52b7

Please sign in to comment.