| Total Complexity | 10 |
| Total Lines | 83 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class ExternalCacheStatefulFile extends ExternalFile implements ICacheStateful |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @var array |
||
| 10 | */ |
||
| 11 | private $cachedState = []; |
||
| 12 | /** |
||
| 13 | * @var \Closure |
||
| 14 | */ |
||
| 15 | private $saveCachedStateCallback; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @param array $cachedState |
||
| 19 | */ |
||
| 20 | public function setCachedStateArray(array $cachedState): void |
||
| 21 | { |
||
| 22 | $this->cachedState = $cachedState; |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @return array |
||
| 27 | */ |
||
| 28 | public function getCachedStateArray(): array |
||
| 29 | { |
||
| 30 | return $this->cachedState; |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param string $format |
||
| 35 | * |
||
| 36 | * @see Factory::$formatterConfigArray |
||
| 37 | * @return int |
||
| 38 | */ |
||
| 39 | public function getCachedAt(string $format): ?int |
||
| 40 | { |
||
| 41 | $cachedAt = $this->cachedState[$format] ?? null; |
||
| 42 | if ($cachedAt <= 0) { |
||
| 43 | $cachedAt = null; |
||
| 44 | } |
||
| 45 | |||
| 46 | return $cachedAt; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @param string $format |
||
| 51 | * @param int $cachedAt |
||
| 52 | */ |
||
| 53 | public function setCachedAt(string $format, int $cachedAt): void |
||
| 54 | { |
||
| 55 | $this->cachedState[$format] = $cachedAt; |
||
| 56 | if ($cachedAt <= 0) { |
||
| 57 | unset($this->cachedState[$format]); |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @param string $format |
||
| 63 | * |
||
| 64 | * @return bool |
||
| 65 | */ |
||
| 66 | public function getIsCached(string $format): bool |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @param \Closure $callback |
||
| 73 | */ |
||
| 74 | public function setSaveCacheCallback(\Closure $callback): void |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @return bool |
||
| 81 | */ |
||
| 82 | public function saveCachedState(): bool |
||
| 89 | } |
||
| 90 | } |