Conditions | 5 |
Paths | 8 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
8 | function cacheResult($key, $phpCode, $cacheLifeTime, $cacheTags) |
||
|
|||
9 | { |
||
10 | $cache = app('cache'); |
||
11 | |||
12 | if ($cacheTags) { |
||
13 | $cache = $cache->tags($cacheTags); |
||
14 | } |
||
15 | |||
16 | if ($cacheLifeTime > 0) { |
||
17 | return $cache->remember($key, $cacheLifeTime, $phpCode); |
||
18 | } |
||
19 | |||
20 | if ($cacheLifeTime < 0) { |
||
21 | return $cache->rememberForever($key, $phpCode); |
||
22 | } |
||
23 | |||
24 | if ($cacheLifeTime === 0) { |
||
25 | return $phpCode(); |
||
26 | } |
||
27 | } |
||
28 | |||
29 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.