Total Complexity | 6 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | trait CachingPreferences |
||
8 | { |
||
9 | /** |
||
10 | * @var bool Determine if caching has been disabled. |
||
11 | */ |
||
12 | protected $cachingDisabled = false; |
||
13 | |||
14 | /** |
||
15 | * Disable ViewModel render caching if the conditional evaluates as true. |
||
16 | * |
||
17 | * @param bool $conditional |
||
18 | * @return $this |
||
19 | */ |
||
20 | public function dontCacheIf(bool $conditional): self |
||
21 | { |
||
22 | if ($conditional) { |
||
23 | $this->cachingDisabled = true; |
||
24 | } |
||
25 | |||
26 | return $this; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Disable ViewModel render caching if the app environment is 'development'. |
||
31 | * |
||
32 | * @return $this |
||
33 | */ |
||
34 | public function dontCacheInDevelopment(): self |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Disable ViewModel render caching if the app environment is 'production'. |
||
45 | * |
||
46 | * @return $this |
||
47 | */ |
||
48 | public function dontCacheInProduction(): self |
||
57 |