Completed
Push — master ( ba4c77...e0502e )
by Vladimir
05:19
created

ArrayCache::remember()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AcquiroPay\Cache;
6
7
use AcquiroPay\Contracts\Cache;
8
use Closure;
9
10
class ArrayCache implements Cache
11
{
12
    protected $items = [];
13
14
    public function remember(string $key, int $minutes, Closure $callback)
15
    {
16
        if(isset($this->items[$key])) {
17
            return $this->items[$key];
18
        }
19
20
        return $this->items[$key] = value($callback);
21
    }
22
}