Lines 100.00% 5 / 5
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 attach 100.00% 4 / 4 100.00% 1 / 1 1
16final readonly class MapOperator implements StreamSource
17{
18    /**
19     * @param StreamSource<TIn> $source
20     * @param Closure(TIn): TOut $mapper
21     */
22    public function __construct(
23        private StreamSource $source,
24        private Closure $mapper,
25    ) {}
26
27    public function attach(SubscriptionScope $scope, Closure $downstream): Subscription
28    {
29        $mapper = $this->mapper;
30
31        return $this->source->attach($scope, static function (mixed $event) use ($mapper, $downstream): void {
32            $downstream($mapper($event));
33        });
34    }
35}