Lines 100.00% 6 / 6
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% 5 / 5 100.00% 1 / 1 1
16final readonly class TakeUntilOperator implements StreamSource
17{
18    /**
19     * @param StreamSource<T> $source
20     * @param EventStream<mixed> $notifier
21     */
22    public function __construct(
23        private StreamSource $source,
24        private EventStream $notifier,
25    ) {}
26
27    public function attach(SubscriptionScope $scope, Closure $downstream): Subscription
28    {
29        $watching = $this->notifier->subscribe(static function () use ($scope): void {
30            $scope->close();
31        });
32
33        $scope->onTeardown($watching->unsubscribe(...));
34
35        return $this->source->attach($scope, $downstream);
36    }
37}