Total Complexity | 8 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class SimpleCacheSchemaProvider implements SchemaProviderInterface |
||
11 | { |
||
12 | public const DEFAULT_KEY = 'Cycle-ORM-Schema'; |
||
13 | private CacheInterface $cache; |
||
14 | private string $key = self::DEFAULT_KEY; |
||
15 | |||
16 | public function __construct(CacheInterface $cache) |
||
19 | } |
||
20 | |||
21 | public function withConfig(array $config): self |
||
26 | } |
||
27 | |||
28 | public function read(?SchemaProviderInterface $nextProvider = null): ?array |
||
29 | { |
||
30 | $schema = $this->cache->get($this->key); |
||
31 | |||
32 | if ($schema !== null || $nextProvider === null) { |
||
33 | return $schema; |
||
34 | } |
||
35 | |||
36 | $schema = $nextProvider->read(); |
||
37 | if ($schema !== null) { |
||
38 | $this->write($schema); |
||
39 | } |
||
40 | return $schema; |
||
41 | } |
||
42 | |||
43 | public function clear(): bool |
||
46 | } |
||
47 | |||
48 | private function write(array $schema): bool |
||
51 | } |
||
52 | } |
||
53 |