Skip to content

Commit

Permalink
is_array instead of is_iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenckens committed Apr 14, 2024
1 parent 8c65144 commit 0c9201c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/behaviors/SearchableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SearchableBehavior extends Behavior

public function validatesCriteria(ScoutIndex $scoutIndex): bool
{
if (is_iterable($scoutIndex->criteria)) {
if (is_array($scoutIndex->criteria)) {
foreach($scoutIndex->criteria as $query) {
$criteria = clone $query;

Expand All @@ -64,7 +64,7 @@ public function getIndices(): Collection
->getSettings()
->getIndices()
->filter(function(ScoutIndex $scoutIndex) {
if(is_iterable($scoutIndex->criteria)){
if(is_array($scoutIndex->criteria)){
$criteriaSiteIds = collect($scoutIndex->criteria)->map(function($criteria){
return Arr::wrap($criteria->siteId);
})->flatten()->unique()->values()->toArray();
Expand Down
2 changes: 1 addition & 1 deletion src/console/controllers/scout/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function actionImport($index = '')
$this->stdout("Added ImportIndex job for '{$engine->scoutIndex->indexName}' to the queue".PHP_EOL, Console::FG_GREEN);
} else {
// check if $engine->scoutIndex->criteria is iterable
if (is_iterable($engine->scoutIndex->criteria)) {
if (is_array($engine->scoutIndex->criteria)) {
// use array_reduce to get the count of elements
$totalElements = array_reduce($engine->scoutIndex->criteria, function ($carry, $query) {
return $carry + $query->count();
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function actionImport()
}

// check if $engine->scoutIndex->criteria is iterable
if (is_iterable($engine->scoutIndex->criteria)) {
if (is_array($engine->scoutIndex->criteria)) {
// use array_reduce to get the count of elements
$elementsCount = array_reduce($engine->scoutIndex->criteria, function ($carry, $query) {
return $carry + $query->count();
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/ImportIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function execute($queue): void
}

// check if $engine->scoutIndex->criteria is iterable
if (is_iterable($engine->scoutIndex->criteria)) {
if (is_array($engine->scoutIndex->criteria)) {
// use array_reduce to get the count of elements
$elementsCount = array_reduce($engine->scoutIndex->criteria, function ($carry, $query) {
return $carry + $query->count();
Expand Down

0 comments on commit 0c9201c

Please sign in to comment.