| Total Complexity | 4 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | trait WithCachedRows |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Whatever we use the cache or not. |
||
| 14 | * |
||
| 15 | * @var bool |
||
| 16 | */ |
||
| 17 | protected bool $useCache = false; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Modify the option to use the cache. |
||
| 21 | * |
||
| 22 | * @return void |
||
| 23 | */ |
||
| 24 | public function useCachedRows(): void |
||
| 25 | { |
||
| 26 | $this->useCache = true; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Function to store and get back queries result from the cache. |
||
| 31 | * |
||
| 32 | * @param mixed $callback The callback function. (The query stored) |
||
| 33 | * |
||
| 34 | * @return mixed |
||
| 35 | * |
||
| 36 | * @throws ContainerExceptionInterface |
||
| 37 | * @throws NotFoundExceptionInterface |
||
| 38 | */ |
||
| 39 | public function cache(mixed $callback): mixed |
||
| 55 | } |
||
| 56 | } |
||
| 57 |