GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CacheDecorator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 58
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A call() 0 23 4
A hashCall() 0 4 1
1
<?php
2
3
namespace Skautis\Wsdl\Decorator\Cache;
4
5
use Skautis\User;
6
use Skautis\Wsdl\Decorator\AbstractDecorator;
7
use Skautis\Wsdl\WebServiceInterface;
8
9
class CacheDecorator extends AbstractDecorator
10
{
11
    /**
12
     * @var CacheInterface
13
     */
14
    protected $cache;
15
16
    /**
17
     * @var array
18
     */
19
    protected static $checkedLoginIds = array();
20
21
    /**
22
     * @param WebServiceInterface $webService
23
     * @param CacheInterface $cache
24
     */
25 2
    public function __construct(WebServiceInterface $webService, CacheInterface $cache)
26
    {
27 2
        $this->webService = $webService;
28 2
        $this->cache = $cache;
29 2
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34 2
    public function call($functionName, array $arguments = [])
35
    {
36 2
        $callHash = $this->hashCall($functionName, $arguments);
37
38
        // Pozaduj alespon 1 supesny request na server (zadna Exception)
39 2
        if (isset($arguments[User::ID_LOGIN]) && !in_array($arguments[User::ID_LOGIN], static::$checkedLoginIds)) {
40 1
            $response = $this->webService->call($functionName, $arguments);
41 1
            $this->cache->set($callHash, $response);
42 1
            static::$checkedLoginIds[] = $arguments[User::ID_LOGIN];
43
44 1
            return $response;
45
        }
46
47 2
        $cachedResponse = $this->cache->get($callHash);
48 2
        if ($cachedResponse !== null) {
49 2
            return $cachedResponse;
50
        }
51
52 1
        $response = $this->webService->call($functionName, $arguments);
53 1
        $this->cache->set($callHash, $response);
54
55 1
        return $response;
56
    }
57
58
    /**
59
     * @var string $functionName
60
     * @var array  $arguments
61
     */
62 2
    protected function hashCall($functionName, array $arguments)
63
    {
64 2
        return $functionName . '?' . http_build_query($arguments);
65
    }
66
}
67