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