| Total Complexity | 7 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| 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) |
||
| 17 | { |
||
| 18 | $this->cache = $cache; |
||
| 19 | } |
||
| 20 | |||
| 21 | public function withConfig(array $config): SchemaProviderInterface |
||
| 22 | { |
||
| 23 | $clone = clone $this; |
||
| 24 | $clone->key = $config['key'] ?? self::DEFAULT_KEY; |
||
| 25 | return $clone; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function read(): ?array |
||
| 29 | { |
||
| 30 | return $this->cache->get($this->key); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function write($schema): bool |
||
| 34 | { |
||
| 35 | return $this->cache->set($this->key, $schema); |
||
| 36 | } |
||
| 37 | |||
| 38 | public function clear(): bool |
||
| 41 | } |
||
| 42 | public function isWritable(): bool |
||
| 43 | { |
||
| 44 | return true; |
||
| 45 | } |
||
| 46 | public function isReadable(): bool |
||
| 49 | } |
||
| 50 | } |
||
| 51 |