Skip to content

Commit

Permalink
refactor: Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jan 30, 2021
1 parent 2797d5d commit 0d87d15
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/Operation/Apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
final class Apply extends AbstractOperation
{
/**
* @psalm-return Closure(callable(T , TKey ): bool ...):Closure (Iterator<TKey, T>): Generator<TKey, T>
* @psalm-return Closure(callable(T , TKey, Iterator<TKey, T>):bool ...): Closure(Iterator<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
{
return
/**
* @psalm-param callable(T, TKey):(bool) ...$callbacks
* @psalm-param callable(T, TKey, Iterator<TKey, T>):bool ...$callbacks
*
* @psalm-return Closure(Iterator<TKey, T>): Generator<TKey, T>
*/
Expand All @@ -33,16 +33,12 @@ public function __invoke(): Closure
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator) use ($callbacks): Generator {
$continue = true;

foreach ($iterator as $key => $value) {
if (true === $continue) {
foreach ($callbacks as $cKey => $callback) {
$result = $callback($value, $key);
foreach ($callbacks as $cKey => $callback) {
$result = $callback($value, $key, $iterator);

if (false === $result) {
unset($callbacks[$cKey]);
}
if (false === $result) {
unset($callbacks[$cKey]);
}
}

Expand Down

0 comments on commit 0d87d15

Please sign in to comment.