Skip to content

Commit

Permalink
replace is_iterable with is_array
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmenich committed Aug 18, 2023
1 parent e879e18 commit 266fd56
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 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 @@ -48,7 +48,7 @@ public function validatesCriteria(ScoutIndex $scoutIndex): bool
}
}
return true;

} else {
$criteria = clone $scoutIndex->criteria;

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
4 changes: 2 additions & 2 deletions src/console/controllers/scout/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ 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();
}, 0);

foreach($engine->scoutIndex->criteria as $query) {
$elementsUpdated = 0;
$batch = $query->batch(
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 @@ -23,7 +23,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 266fd56

Please sign in to comment.