| Total Complexity | 3 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | trait GetCache |
||
| 11 | { |
||
| 12 | private FilesystemAdapter $cache; |
||
| 13 | private ManagerRegistry $doctrine; |
||
| 14 | private string $persistentObjectName; |
||
| 15 | |||
| 16 | public function __construct(ManagerRegistry $doctrine) |
||
| 17 | { |
||
| 18 | $this->cache = new FilesystemAdapter(); |
||
| 19 | $this->doctrine = $doctrine; |
||
| 20 | } |
||
| 21 | |||
| 22 | public function getCount(string $key, string $class): int |
||
| 23 | { |
||
| 24 | $this->persistentObjectName = $class; |
||
| 25 | |||
| 26 | $count = $this->cache->get($key, fn () => $this->countItems()); |
||
| 27 | |||
| 28 | return (int) $count; |
||
| 29 | } |
||
| 30 | |||
| 31 | private function countItems(): int |
||
| 36 | } |
||
| 37 | } |
||
| 38 |