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.
Completed
Push — supported-php-versions ( b1e0a1...542ebe )
by
unknown
06:40
created

Config   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 164
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 97.14%

Importance

Changes 0
Metric Value
wmc 14
lcom 2
cbo 1
dl 0
loc 164
ccs 34
cts 35
cp 0.9714
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getAppId() 0 4 1
A isTestMode() 0 4 1
A setTestMode() 0 5 1
A getCache() 0 4 1
A setCache() 0 5 1
A getCompression() 0 4 1
A setCompression() 0 5 1
A getBaseUrl() 0 4 2
A getSoapOptions() 0 16 3
1
<?php
2
3
namespace Skautis;
4
5
/**
6
 * Třída pro uživatelské nastavení
7
 */
8
class Config
9
{
10
11
    const CACHE_ENABLED = true;
12
    const CACHE_DISABLED = false;
13
14
    const TESTMODE_ENABLED = true;
15
    const TESTMODE_DISABLED = false;
16
17
    const COMPRESSION_ENABLED = true;
18
    const COMPRESSION_DISABLED = false;
19
20
    const URL_TEST = "http://test-is.skaut.cz/";
21
    const URL_PRODUCTION = "https://is.skaut.cz/";
22
23
    /**
24
     * @var string
25
     */
26
    private $appId;
27
28
    /**
29
     * Používat testovací SkautIS?
30
     *
31
     * @var bool
32
     */
33
    private $testMode;
34
35
    /**
36
     * Používat kompresi?
37
     *
38
     * @var bool
39
     */
40
    private $compression;
41
42
    /**
43
     * Cachovat WSDL?
44
     *
45
     * @var bool
46
     */
47
    protected $cache;
48
49
50
    /**
51
     * @param string $appId Id aplikace od správce skautISu
52
     * @param bool $isTestMode používat testovací SkautIS?
53
     * @param bool $cache použít kompresi?
54
     * @param bool $compression cachovat WDSL?
55
     * @throws InvalidArgumentException
56
     */
57 8
    public function __construct($appId, $isTestMode = false, $cache = true, $compression = true)
58
    {
59 8
        if (empty($appId)) {
60
            throw new InvalidArgumentException("AppId cannot be empty.");
61
        }
62 8
        $this->appId = $appId;
63 8
        $this->setTestMode($isTestMode);
64 8
        $this->setCache($cache);
65 8
        $this->setCompression($compression);
66 8
    }
67
68
    /**
69
     * @return string
70
     */
71 2
    public function getAppId()
72
    {
73 2
        return $this->appId;
74
    }
75
76
    /**
77
     * @return bool
78
     */
79 4
    public function isTestMode()
80
    {
81 4
        return $this->testMode;
82
    }
83
84
    /**
85
     * @param bool $isTestMode
86
     * @return self
87
     */
88 8
    public function setTestMode($isTestMode = true)
89
    {
90 8
        $this->testMode = (bool) $isTestMode;
91 8
        return $this;
92
    }
93
94
    /**
95
     * Zjistí, jestli je WSDL cachované
96
     *
97
     * @return bool
98
     */
99 3
    public function getCache()
100
    {
101 3
        return $this->cache;
102
    }
103
104
    /**
105
     * Vypne/zapne cachovaní WSDL
106
     *
107
     * @param bool $enabled
108
     * @return self
109
     */
110 8
    public function setCache($enabled)
111
    {
112 8
        $this->cache = (bool) $enabled;
113 8
        return $this;
114
    }
115
116
    /**
117
     * Zjistí, jestli se používá komprese dotazů na WSDL
118
     *
119
     * @return bool
120
     */
121 3
    public function getCompression()
122
    {
123 3
        return $this->compression;
124
    }
125
126
    /**
127
     * Vypne/zapne kompresi dotazů na WSDL
128
     *
129
     * @param $enabled
130
     * @return self
131
     */
132 8
    public function setCompression($enabled)
133
    {
134 8
        $this->compression = (bool) $enabled;
135 8
        return $this;
136
    }
137
138
    /**
139
     * Vací začátek URL adresy
140
     *
141
     * @return string
142
     */
143 2
    public function getBaseUrl()
144
    {
145 2
        return $this->testMode ? self::URL_TEST : self::URL_PRODUCTION;
146
    }
147
148
    /**
149
     * Na základě nastavení vrací argumenty pro SoapClient
150
     *
151
     * @see \SoapClient
152
     *
153
     * @return array
154
     */
155 1
    public function getSoapOptions()
156
    {
157
        $soapOptions = [
158 1
            'ID_Application' => $this->appId,
159 1
            'soap_version' => SOAP_1_2,
160 1
            'encoding' => 'utf-8',
161
        ];
162
163 1
        if ($this->compression) {
164 1
            $soapOptions['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP;
165
        }
166
167 1
        $soapOptions['cache_wsdl'] = $this->cache ? WSDL_CACHE_BOTH : WSDL_CACHE_NONE;
168
169 1
        return $soapOptions;
170
    }
171
}
172