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
Pull Request — 2.x (#64)
by Jindřich
07:10
created

Config::getBaseUrl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 2
eloc 2
nc 2
nop 0
crap 6
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 = "https://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
    public function __construct($appId, $isTestMode = false, $cache = true, $compression = true)
58
    {
59
        if (empty($appId)) {
60
            throw new InvalidArgumentException("AppId cannot be empty.");
61
        }
62
        $this->appId = $appId;
63
        $this->setTestMode($isTestMode);
64
        $this->setCache($cache);
65
        $this->setCompression($compression);
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getAppId()
72
    {
73
        return $this->appId;
74
    }
75
76
    /**
77
     * @return bool
78
     */
79
    public function isTestMode()
80
    {
81
        return $this->testMode;
82
    }
83
84
    /**
85
     * @param bool $isTestMode
86
     * @return self
87
     */
88
    public function setTestMode($isTestMode = true)
89
    {
90
        $this->testMode = (bool) $isTestMode;
91
        return $this;
92
    }
93
94
    /**
95
     * Zjistí, jestli je WSDL cachované
96
     *
97
     * @return bool
98
     */
99
    public function getCache()
100
    {
101
        return $this->cache;
102
    }
103
104
    /**
105
     * Vypne/zapne cachovaní WSDL
106
     *
107
     * @param bool $enabled
108
     * @return self
109
     */
110
    public function setCache($enabled)
111
    {
112
        $this->cache = (bool) $enabled;
113
        return $this;
114
    }
115
116
    /**
117
     * Zjistí, jestli se používá komprese dotazů na WSDL
118
     *
119
     * @return bool
120
     */
121
    public function getCompression()
122
    {
123
        return $this->compression;
124
    }
125
126
    /**
127
     * Vypne/zapne kompresi dotazů na WSDL
128
     *
129
     * @param $enabled
130
     * @return self
131
     */
132
    public function setCompression($enabled)
133
    {
134
        $this->compression = (bool) $enabled;
135
        return $this;
136
    }
137
138
    /**
139
     * Vací začátek URL adresy
140
     *
141
     * @return string
142
     */
143
    public function getBaseUrl()
144
    {
145
        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
    public function getSoapOptions()
156
    {
157
        $soapOptions = [
158
            'ID_Application' => $this->appId,
159
            'soap_version' => SOAP_1_2,
160
            'encoding' => 'utf-8',
161
        ];
162
163
        if ($this->compression) {
164
            $soapOptions['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP;
165
        }
166
167
        $soapOptions['cache_wsdl'] = $this->cache ? WSDL_CACHE_BOTH : WSDL_CACHE_NONE;
168
169
        return $soapOptions;
170
    }
171
}
172