Passed
Push — master ( 5af0f6...36a1fd )
by Gabriel
14:51
created

Repository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A remember() 0 9 2
1
<?php
2
3
namespace Nip\Cache\Stores;
4
5
use Closure;
6
use Symfony\Component\Cache\Psr16Cache;
7
8
/**
9
 * Class Repository
10
 * @package Nip\Cache\Stores
11
 */
12
class Repository extends Psr16Cache
13
{
14
15
    /**
16
     * Get an item from the cache, or execute the given Closure and store the result.
17
     *
18
     * @param  string  $key
19
     * @param  \DateTimeInterface|\DateInterval|int|null  $ttl
20
     * @param  \Closure  $callback
21
     * @return mixed
22
     */
23
    public function remember($key, $ttl, Closure $callback)
24
    {
25
        if ($this->has($key)) {
26
            return $this->get($key);
27
        }
28
29
        $this->set($key, $value = $callback(), $ttl);
30
31
        return $value;
32
    }
33
}
34