Lines 66.66% 4 / 6
Methods 50.00% 2 / 4
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 getValue 100.00% 3 / 3 100.00% 1 / 1 2
 keyToResultCache 0.00% 0 / 1 0.00% 0 / 1 2
 keyFromResultCache 0.00% 0 / 1 0.00% 0 / 1 2
11final readonly class ManifestResultCacheValue implements ResultCacheValueExtension
12{
13    public const string MANIFEST_KEY = 'manifest';
14
15    private const string WITHOUT_MANIFEST = 'none';
16
17    private const string FROM_OLDER_MAJOR = 'older-major';
18
19    public function __construct(private ManifestCatalogLoader $manifests) {}
20
21    public function getValue(string $key): string
22    {
23        if ($this->manifests->findOlderMajorNamespace() !== null) {
24            return self::FROM_OLDER_MAJOR;
25        }
26
27        return $this->manifests->findCatalog()?->computeHash() ?? self::WITHOUT_MANIFEST;
28    }
29
30    public function keyToResultCache(string $key): string
31    {
32        return $key;
33    }
34
35    public function keyFromResultCache(string $storedKey): string
36    {
37        return $storedKey;
38    }
39}