Lines 100.00% 5 / 5
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 readSnapshot 100.00% 4 / 4 100.00% 1 / 1 3
12final readonly class SnapshotFileReader
13{
14    public function __construct(private SnapshotCodec $codec) {}
15
16    /** @throws CodegenException */
17    public function readSnapshot(string $path, LoggerInterface $logger = new NullLogger()): Snapshot
18    {
19        $snapshotJson = is_file($path) ? file_get_contents($path) : false;
20
21        if ($snapshotJson === false) {
22            throw CodegenException::createForReason(CodegenError::SnapshotUnreadable, path: $path);
23        }
24
25        return $this->codec->decodeSnapshot($snapshotJson, $path, $logger);
26    }
27}