| Total Complexity | 5 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class CacheableBlock extends Block implements CacheableInterface |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | private $key; |
||
| 13 | /** |
||
| 14 | * @var int |
||
| 15 | */ |
||
| 16 | private $ttl; |
||
| 17 | /** |
||
| 18 | * @var array |
||
| 19 | */ |
||
| 20 | private $tags; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param ThemeDescriptorInterface $themeDescriptor |
||
| 24 | * @param mixed[] $context |
||
| 25 | */ |
||
| 26 | public function __construct(ThemeDescriptorInterface $themeDescriptor, array $context, string $key, int $ttl, array $tags = []) |
||
| 32 | } |
||
| 33 | |||
| 34 | public function jsonSerialize() |
||
| 35 | { |
||
| 36 | $json = parent::jsonSerialize(); |
||
| 37 | $json['key'] = $this->key; |
||
| 38 | $json['ttl'] = $this->ttl; |
||
| 39 | $json['tags'] = $this->tags; |
||
| 40 | return $json; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Returns the time to live of this object, in seconds. |
||
| 45 | * |
||
| 46 | * @return int |
||
| 47 | */ |
||
| 48 | public function getTtl(): int |
||
| 49 | { |
||
| 50 | return $this->ttl; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Returns the tags applied to this object. |
||
| 55 | * Useful for purging all elements by a certain tag. |
||
| 56 | * |
||
| 57 | * @return string[] |
||
| 58 | */ |
||
| 59 | public function getTags(): array |
||
| 60 | { |
||
| 61 | return $this->tags; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Returns the cache key for this object. |
||
| 66 | * |
||
| 67 | * @return string |
||
| 68 | */ |
||
| 69 | public function getKey(): string |
||
| 72 | } |
||
| 73 | } |
||
| 74 |