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::hashCall()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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