Skip to content

Commit

Permalink
Merge pull request #355 from norkunas/typehint
Browse files Browse the repository at this point in the history
Fix phpdoc typehint
  • Loading branch information
norkunas authored Oct 4, 2024
2 parents a6ee705 + e98e4c8 commit 4c5f1fc
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,20 @@ 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];
}

$data = [];
foreach ($searchableEntities as $entity) {
$searchableArray = $entity->getSearchableArray();
if (null === $searchableArray || 0 === \count($searchableArray)) {
if ([] === $searchableArray) {
continue;
}

Expand All @@ -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 4c5f1fc

Please sign in to comment.