| Total Complexity | 2 |
| Total Lines | 15 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 18 | trait LocalCacheTrait { |
||
| 19 | |||
| 20 | /** @phpstan-var array<string, array<string, CachedType>> $localCache */ |
||
| 21 | protected array $localCache = []; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @phpstan-param callable():CachedType $createItem |
||
| 25 | * @phpstan-return CachedType |
||
| 26 | */ |
||
| 27 | protected function cachedGet(string $userId, ?string $key, callable $createItem) { |
||
| 28 | return $this->localCache[$userId][$key] ?? $this->localCache[$userId][$key] = $createItem(); |
||
| 29 | } |
||
| 30 | |||
| 31 | protected function invalidateCache(string $userId) : void { |
||
| 33 | } |
||
| 34 | |||
| 35 | } |