| Conditions | 3 |
| Paths | 2 |
| Total Lines | 16 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 35 | public function cache($callback) |
||
| 36 | { |
||
| 37 | $cacheKey = $this->id; |
||
| 38 | |||
| 39 | // If we use the cache and the cache has the id, return it. |
||
| 40 | if ($this->useCache && cache()->has($cacheKey)) { |
||
| 41 | return cache()->get($cacheKey); |
||
| 42 | } |
||
| 43 | |||
| 44 | // Get the callback result. |
||
| 45 | $result = $callback(); |
||
| 46 | |||
| 47 | // Store the result in the cache. |
||
| 48 | cache()->put($cacheKey, $result); |
||
| 49 | |||
| 50 | return $result; |
||
| 51 | } |
||
| 53 |