| @@ 14-30 (lines=17) @@ | ||
| 11 | ||
| 12 | namespace Fp\Reducer; |
|
| 13 | ||
| 14 | class Filtering implements Reducer |
|
| 15 | { |
|
| 16 | use Mixin\Stateless; |
|
| 17 | use Mixin\WithCallback; |
|
| 18 | ||
| 19 | public function step($result, $current) |
|
| 20 | { |
|
| 21 | if ($this->callback->__invoke($current)) { |
|
| 22 | return $this->next_reducer->step( |
|
| 23 | $result, $current |
|
| 24 | ); |
|
| 25 | } |
|
| 26 | ||
| 27 | return $result; |
|
| 28 | } |
|
| 29 | ||
| 30 | } |
|
| 31 | ||
| @@ 14-25 (lines=12) @@ | ||
| 11 | ||
| 12 | namespace Fp\Reducer; |
|
| 13 | ||
| 14 | class Mapping implements Reducer |
|
| 15 | { |
|
| 16 | use Mixin\Stateless; |
|
| 17 | use Mixin\WithCallback; |
|
| 18 | ||
| 19 | public function step($result, $current) |
|
| 20 | { |
|
| 21 | return $this->next_reducer->step( |
|
| 22 | $result, $this->callback->__invoke($current) |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | } |
|
| 26 | ||