| Total Complexity | 7 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class Formatted |
||
| 16 | { |
||
| 17 | /** @var Interfaces\ICache */ |
||
| 18 | protected $cache = null; |
||
| 19 | /** @var Interfaces\IFormat */ |
||
| 20 | protected $format = null; |
||
| 21 | |||
| 22 | 1 | public function __construct(Interfaces\ICache $cache, Interfaces\IFormat $format) |
|
| 23 | { |
||
| 24 | 1 | $this->cache = $cache; |
|
| 25 | 1 | $this->format = $format; |
|
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param string $what |
||
| 30 | * @throws CacheException |
||
| 31 | */ |
||
| 32 | 1 | public function init(string $what): void |
|
| 33 | { |
||
| 34 | 1 | $this->cache->init($what); |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @throws CacheException |
||
| 39 | * @return bool |
||
| 40 | */ |
||
| 41 | 1 | public function exists(): bool |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param mixed $content |
||
| 48 | * @throws CacheException |
||
| 49 | * @return bool |
||
| 50 | */ |
||
| 51 | 1 | public function set($content): bool |
|
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @throws CacheException |
||
| 58 | * @return mixed |
||
| 59 | */ |
||
| 60 | 1 | public function get() |
|
| 61 | { |
||
| 62 | 1 | return $this->exists() ? $this->format->unpack($this->cache->get()) : null; |
|
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @throws CacheException |
||
| 67 | */ |
||
| 68 | 1 | public function clear(): void |
|
| 71 | } |
||
| 72 | } |
||
| 73 |