Lines
0.00%
0 / 2
Functions and Methods
0.00%
0 / 2
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| DispatchSource | 0.00% | 0 / 2 | 0.00% | 0 / 2 | 6 | 0.00% | 0 / 1 | |||
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| attach | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Dispatch; | |
| 6 | ||
| 7 | use Closure; | |
| 8 | use Stewart\Contracts\Registry\EntityFilter; | |
| 9 | use Stewart\Contracts\Selector\Selector; | |
| 10 | use Stewart\Contracts\Subscription; | |
| 11 | use Stewart\Runtime\Model\ResourceScope; | |
| 12 | use Stewart\Runtime\Model\SubscriptionKind; | |
| 13 | use Stewart\Support\Stream\StreamSource; | |
| 14 | use Stewart\Support\Stream\SubscriptionScope; | |
| 15 | use Stewart\Support\Wire\TriggerSpec; | |
| 16 | ||
| 17 | /** | |
| 18 | * @template T | |
| 19 | * @implements StreamSource<T> | |
| 20 | */ | |
| 21 | final readonly class DispatchSource implements StreamSource | |
| 22 | { | |
| 23 | public function __construct( | |
| 24 | private LocalDispatcher $dispatcher, | |
| 25 | private ResourceScope $scope, | |
| 26 | private SubscriptionKind $kind, | |
| 27 | private Selector $selector, | |
| 28 | private ?TriggerSpec $trigger = null, | |
| 29 | private ?EntityFilter $entityFilter = null, | |
| 30 | ) {} | |
| 31 | ||
| 32 | public function attach(SubscriptionScope $scope, Closure $downstream): Subscription | |
| 33 | { | |
| 34 | return $this->dispatcher->register($this->scope, $this->kind, $this->selector, $scope, $downstream, $this->trigger, $this->entityFilter); | |
| 35 | } | |
| 36 | } |