Completed
Push — 6.0 ( c6d21a...a43f83 )
by yun
15:10 queued 11:06
created

CacheStore::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 6
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 10
c 0
b 0
f 0
1
<?php
2
// +----------------------------------------------------------------------
3
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
4
// +----------------------------------------------------------------------
5
// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
6
// +----------------------------------------------------------------------
7
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
8
// +----------------------------------------------------------------------
9
// | Author: yunwuxin <[email protected]>
10
// +----------------------------------------------------------------------
11
declare (strict_types = 1);
12
13
namespace think\filesystem;
14
15
use League\Flysystem\Cached\Storage\AbstractCache;
16
use Psr\SimpleCache\CacheInterface;
17
18
class CacheStore extends AbstractCache
1 ignored issue
show
Coding Style introduced by
Missing doc comment for class CacheStore
Loading history...
19
{
20
    protected $store;
21
22
    protected $key;
23
24
    protected $expire;
25
26 1
    public function __construct(CacheInterface $store, $key = 'flysystem', $expire = null)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
27
    {
28 1
        $this->key    = $key;
29 1
        $this->store  = $store;
30 1
        $this->expire = $expire;
31 1
    }
32
33
    /**
34
     * Store the cache.
35
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
36 1
    public function save()
37
    {
38 1
        $contents = $this->getForStorage();
39
40 1
        $this->store->set($this->key, $contents, $this->expire);
41 1
    }
42
43
    /**
44
     * Load the cache.
45
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
46 1
    public function load()
47
    {
48 1
        $contents = $this->store->get($this->key);
49
50 1
        if (!is_null($contents)) {
51
            $this->setFromStorage($contents);
52
        }
53 1
    }
54
}
55