Lines
100.00%
4 / 4
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| CachedStateReader | 100.00% | 4 / 4 | 100.00% | 2 / 2 | 3 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| readCurrentStates | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\State; | |
| 6 | ||
| 7 | use Stewart\Contracts\Registry\EntityFilter; | |
| 8 | use Stewart\Contracts\Selector\Selector; | |
| 9 | use Stewart\Contracts\State\Collection\EntityStateCollection; | |
| 10 | use Stewart\Runtime\Registry\RegistryCache; | |
| 11 | use Stewart\Support\State\CurrentStateReader; | |
| 12 | ||
| 13 | final readonly class CachedStateReader implements CurrentStateReader | |
| 14 | { | |
| 15 | public function __construct( | |
| 16 | private StateCache $states, | |
| 17 | private RegistryCache $registry, | |
| 18 | private Selector|EntityFilter $match, | |
| 19 | ) {} | |
| 20 | ||
| 21 | public function readCurrentStates(): EntityStateCollection | |
| 22 | { | |
| 23 | return $this->match instanceof EntityFilter | |
| 24 | ? $this->states->getAllStates()->filterByEntityFilter($this->match, $this->registry) | |
| 25 | : $this->states->filterBySelector($this->match); | |
| 26 | } | |
| 27 | } |