Total Complexity | 7 |
Total Lines | 59 |
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 | /** |
||
14 | * @param array $cachedState |
||
15 | */ |
||
16 | public function setCachedStateArray(array $cachedState): void |
||
17 | { |
||
18 | $this->cachedState = $cachedState; |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @return array |
||
23 | */ |
||
24 | public function getCachedStateArray(): array |
||
25 | { |
||
26 | return $this->cachedState; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string $format |
||
31 | * |
||
32 | * @see Factory::$formatterConfigArray |
||
33 | * @return int |
||
34 | */ |
||
35 | public function getCachedAt(string $format): ?int |
||
36 | { |
||
37 | $cachedAt = $this->cachedState[$format] ?? null; |
||
38 | if ($cachedAt <= 0) { |
||
39 | $cachedAt = null; |
||
40 | } |
||
41 | |||
42 | return $cachedAt; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param string $format |
||
47 | * @param int $cachedAt |
||
48 | */ |
||
49 | public function setCachedAt(string $format, int $cachedAt): void |
||
50 | { |
||
51 | $this->cachedState[$format] = $cachedAt; |
||
52 | if ($cachedAt <= 0) { |
||
53 | unset($this->cachedState[$format]); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param string $format |
||
59 | * |
||
60 | * @return bool |
||
61 | */ |
||
62 | public function getIsCached(string $format): bool |
||
65 | } |
||
66 | } |