Lines
100.00%
2 / 2
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| StoreBackendConnector | 100.00% | 2 / 2 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| connectToBackend | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Store; | |
| 6 | ||
| 7 | use Stewart\Contracts\Exception\StoreException; | |
| 8 | use Stewart\Contracts\Time\Clock; | |
| 9 | use Stewart\Store\Exception\StoreSetupException; | |
| 10 | ||
| 11 | final readonly class StoreBackendConnector | |
| 12 | { | |
| 13 | public function __construct( | |
| 14 | private StoreBackendRegistry $storeBackends, | |
| 15 | private Clock $clock, | |
| 16 | ) {} | |
| 17 | ||
| 18 | /** @throws StoreException|StoreSetupException */ | |
| 19 | public function connectToBackend(StoreDsn $dsn, StoreTiming $timing): GuardedStoreBackend | |
| 20 | { | |
| 21 | return new GuardedStoreBackend($this->storeBackends->requireFactoryForDsn($dsn)->createBackend($dsn, $timing), $dsn, $timing, $this->clock); | |
| 22 | } | |
| 23 | } |