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
3declare(strict_types=1);
4
5namespace Stewart\Store;
6
7use Stewart\Contracts\Exception\StoreException;
8use Stewart\Contracts\Time\Clock;
9use Stewart\Store\Exception\StoreSetupException;
10
11final 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}