| @@ 26-42 (lines=17) @@ | ||
| 23 | * |
|
| 24 | * @return \Pipes\Pipe |
|
| 25 | */ |
|
| 26 | public function stopIf($______callback, $______allArgs = false) |
|
| 27 | { |
|
| 28 | $iterator = $this->getIterator(); |
|
| 29 | $pipe = $this; |
|
| 30 | ||
| 31 | $generator = function () use ($pipe, $iterator, $______callback, $______allArgs) { |
|
| 32 | foreach ($iterator as $key => $value) { |
|
| 33 | if ($pipe->executeCallback($______callback, $______allArgs, $value, $key, $iterator) |
|
| 34 | ) { |
|
| 35 | return; |
|
| 36 | } // @codeCoverageIgnore |
|
| 37 | yield $key => $value; |
|
| 38 | } |
|
| 39 | }; |
|
| 40 | ||
| 41 | return $this->chainWith($generator()); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Stops the iteration if the callback returns a true-ish value. |
|
| @@ 63-79 (lines=17) @@ | ||
| 60 | * |
|
| 61 | * @return \Pipes\Pipe |
|
| 62 | */ |
|
| 63 | public function continueIf($______callback, $______allArgs = false) |
|
| 64 | { |
|
| 65 | $iterator = $this->getIterator(); |
|
| 66 | $pipe = $this; |
|
| 67 | ||
| 68 | $generator = function () use ($pipe, $iterator, $______callback, $______allArgs) { |
|
| 69 | foreach ($iterator as $key => $value) { |
|
| 70 | if (!$pipe->executeCallback($______callback, $______allArgs, $value, $key, $iterator) |
|
| 71 | ) { |
|
| 72 | return; |
|
| 73 | } // @codeCoverageIgnore |
|
| 74 | yield $key => $value; |
|
| 75 | } |
|
| 76 | }; |
|
| 77 | ||
| 78 | return $this->chainWith($generator()); |
|
| 79 | } |
|
| 80 | } |
|
| 81 | ||