Repository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 5
c 2
b 1
f 0
dl 0
loc 19
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
     * Get an item from the cache, or execute the given Closure and store the result.
16
     *
17
     * @param  string  $key
18
     * @param  \DateTimeInterface|\DateInterval|int|null  $ttl
19
     * @param  \Closure  $callback
20
     * @return mixed
21
     */
22
    public function remember($key, $ttl, Closure $callback)
23
    {
24
        if ($this->has($key)) {
25
            return $this->get($key);
26
        }
27
28
        $this->set($key, $value = $callback(), $ttl);
29
30
        return $value;
31
    }
32
}
33