Passed
Pull Request — master (#88)
by Arman
03:00
created

Cache   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getAdapter() 0 3 1
A __call() 0 7 2
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.8.0
13
 */
14
15
namespace Quantum\Libraries\Cache;
16
17
use Quantum\Exceptions\AppException;
18
use Psr\SimpleCache\CacheInterface;
19
20
/**
21
 *
22
 */
23
class Cache
24
{
25
26
    /**
27
     * @var Psr\SimpleCache\CacheInterface
0 ignored issues
show
Bug introduced by
The type Quantum\Libraries\Cache\...pleCache\CacheInterface was not found. Did you mean Psr\SimpleCache\CacheInterface? If so, make sure to prefix the type with \.
Loading history...
28
     */
29
    private $adapter;
30
31
    /**
32
     * Cache constructor
33
     * @param Psr\SimpleCache\CacheInterface $cacheAdapter
34
     */
35
    public function __construct(CacheInterface $cacheAdapter)
36
    {
37
        $this->adapter = $cacheAdapter;
0 ignored issues
show
Documentation Bug introduced by
It seems like $cacheAdapter of type Psr\SimpleCache\CacheInterface is incompatible with the declared type Quantum\Libraries\Cache\...pleCache\CacheInterface of property $adapter.

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...
38
    }
39
40
    /**
41
     * Gets the current adapter
42
     * @return Psr\SimpleCache\CacheInterface
43
     */
44
    public function getAdapter(): CacheInterface
45
    {
46
        return $this->adapter;
47
    }
48
49
    /**
50
     * @param string $method
51
     * @param array|null $arguments
52
     * @return mixed
53
     * @throws \Quantum\Exceptions\AppException
54
     */
55
    public function __call(string $method, ?array $arguments)
56
    {
57
        if (!method_exists($this->adapter, $method)) {
58
            throw AppException::methodNotSupported($method, get_class($this->adapter));
59
        }
60
61
        return $this->adapter->$method(...$arguments);
62
    }
63
64
}
65