Completed
Push — master ( 2c7ea9...284ef7 )
by Iman
01:59
created

Cache::cacheResult()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 10
nc 8
nop 4
1
<?php
2
3
namespace Imanghafoori\Widgets\Utils;
4
5
6
class Cache
7
{
8
    function cacheResult($key, $phpCode, $cacheLifeTime, $cacheTags)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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
}