YiiCache   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A load() 0 7 2
A save() 0 4 1
1
<?php
2
/**
3
 * This file is part of the 2amigos/yii2-flysystem-component project.
4
 *
5
 * (c) 2amigOS! <http://2amigos.us/>
6
 *
7
 * For the full copyright and license information, please view
8
 * the LICENSE file that was distributed with this source code.
9
 */
10
namespace dosamigos\flysystem\cache;
11
12
use League\Flysystem\Cached\Storage\AbstractCache;
13
use yii\caching\Cache;
14
15
class YiiCache extends AbstractCache
16
{
17
    /**
18
     * @var Cache
19
     */
20
    protected $yiiCache;
21
    /**
22
     * @var string
23
     */
24
    protected $key;
25
    /**
26
     * @var integer
27
     */
28
    protected $duration;
29
    /**
30
     * @param Cache $cache
31
     * @param string $key
32
     * @param integer $duration
33
     */
34
    public function __construct(Cache $cache, $key = 'flysystem', $duration = 0)
35
    {
36
        $this->cache = $cache;
0 ignored issues
show
Documentation Bug introduced by
It seems like $cache of type object<yii\caching\Cache> is incompatible with the declared type array of property $cache.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
37
        $this->key = $key;
38
        $this->duration = $duration;
39
    }
40
    /**
41
     * @inheritdoc
42
     */
43
    public function load()
44
    {
45
        $contents = $this->cache->get($this->key);
0 ignored issues
show
Bug introduced by
The method get cannot be called on $this->cache (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
46
        if ($contents !== false) {
47
            $this->setFromStorage($contents);
48
        }
49
    }
50
    /**
51
     * @inheritdoc
52
     */
53
    public function save()
54
    {
55
        $this->cache->set($this->key, $this->getForStorage(), $this->duration);
0 ignored issues
show
Bug introduced by
The method set cannot be called on $this->cache (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
56
    }
57
}
58