Skip to content

Commit 7f8b5c4

Browse files
committed
Simplify is_builder_pipeline
1 parent f3b4961 commit 7f8b5c4

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

src/functions.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -336,28 +336,17 @@ function is_pipeline(array|object $pipeline, bool $allowEmpty = false): bool
336336
*/
337337
function is_builder_pipeline(array $pipeline): bool
338338
{
339-
if (! $pipeline) {
339+
if (! $pipeline || ! array_is_list($pipeline)) {
340340
return false;
341341
}
342342

343-
if (! array_is_list($pipeline)) {
344-
return false;
345-
}
346-
347-
$result = false;
348343
foreach ($pipeline as $stage) {
349-
if (! is_array($stage) && ! is_object($stage)) {
350-
return false;
351-
}
352-
353344
if ($stage instanceof StageInterface) {
354-
$result = true;
355-
} elseif (! is_first_key_operator($stage)) {
356-
return false;
345+
return true;
357346
}
358347
}
359348

360-
return $result;
349+
return false;
361350
}
362351

363352
/**

tests/FunctionsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ public function provideStagePipelines(): iterable
327327
yield 'map of stages' => [false, [1 => new MatchStage([])]];
328328
yield 'stages' => [true, [new MatchStage([]), new LimitStage(1)]];
329329
yield 'stages and operators' => [true, [new MatchStage([]), ['$limit' => 1]]];
330-
yield 'stages and invalid' => [false, [new MatchStage([]), ['foo' => 'bar']]];
331330
}
332331

333332
/** @dataProvider provideWriteConcerns */

0 commit comments

Comments
 (0)