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 — 3.x ( 52ff30...48a2e9 )
by Jindřich
12s queued 11s
created

Config::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 4
dl 0
loc 14
ccs 7
cts 8
cp 0.875
crap 2.0078
rs 9.7998
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Skaut\Skautis;
5
6
/**
7
 * Třída pro uživatelské nastavení
8
 */
9
final class Config
10
{
11
12
    public const CACHE_ENABLED = true;
13
    public const CACHE_DISABLED = false;
14
15
    public const TEST_MODE_ENABLED = true;
16
    public const TEST_MODE_DISABLED = false;
17
18
    public const COMPRESSION_ENABLED = true;
19
    public const COMPRESSION_DISABLED = false;
20
21
    private const URL_TEST = 'https://test-is.skaut.cz/';
22
    private const URL_PRODUCTION = 'https://is.skaut.cz/';
23
24
    /**
25
     * @var string
26
     */
27
    private $appId;
28
29
    /**
30
     * Používat testovací SkautIS?
31
     *
32
     * @var bool
33
     */
34
    private $testMode;
35
36
    /**
37
     * Používat kompresi?
38
     *
39
     * @var bool
40
     */
41
    private $compression;
42
43
    /**
44
     * Cachovat WSDL?
45
     *
46
     * @var bool
47
     */
48
    protected $cache;
49
50
51
    /**
52
     * @param string $appId Id aplikace od správce skautISu
53
     * @param bool $isTestMode používat testovací SkautIS?
54
     * @param bool $cache použít kompresi?
55
     * @param bool $compression cachovat WDSL?
56
     * @throws InvalidArgumentException
57
     */
58 18
    public function __construct(
59
      string $appId,
60
      bool $isTestMode = self::TEST_MODE_ENABLED,
61
      bool $cache = self::CACHE_ENABLED,
62
      bool $compression = self::COMPRESSION_ENABLED
63
    ) {
64 18
        if (empty($appId)) {
65
            throw new InvalidArgumentException('AppId cannot be empty.');
66
        }
67 18
        $this->appId = $appId;
68 18
        $this->testMode = $isTestMode;
69 18
        $this->cache = $cache;
70 18
        $this->compression = $compression;
71 18
    }
72
73 4
    public function getAppId(): string
74
    {
75 4
        return $this->appId;
76
    }
77
78 3
    public function isTestMode(): bool
79
    {
80 3
        return $this->testMode;
81
    }
82
83
    /**
84
     * Zjistí, jestli je WSDL cachované
85
     */
86 3
    public function isCacheEnabled(): bool
87
    {
88 3
        return $this->cache;
89
    }
90
91
    /**
92
     * Zjistí, jestli se používá komprese dotazů na WSDL
93
     */
94 3
    public function isCompressionEnabled(): bool
95
    {
96 3
        return $this->compression;
97
    }
98
99
    /**
100
     * Vací začátek URL adresy
101
     */
102 11
    public function getBaseUrl(): string
103
    {
104 11
        return $this->testMode ? self::URL_TEST : self::URL_PRODUCTION;
105
    }
106
107
    /**
108
     * Na základě nastavení vrací argumenty pro SoapClient
109
     * Neumožňujeme uživateli primo modifikovat options aby byly vzdy validni a kompatibilni se Skautis API
110
     *
111
     * @see \SoapClient
112
     *
113
     * @return array<string, mixed>
0 ignored issues
show
Documentation introduced by
The doc-type array<string, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
114
     */
115 2
    public function getSoapOptions(): array
116
    {
117
        $soapOptions = [
118 2
            'ID_Application' => $this->appId,
119 2
            'soap_version' => SOAP_1_2,
120 2
            'encoding' => 'utf-8',
121 2
            'ssl_method' => SOAP_SSL_METHOD_TLS,
122
            'exceptions' => true,
123
            'trace' => true,
124 2
            'user_agent' => 'Skautis PHP library',
125
            'keep_alive' => true
126
        ];
127
128 2
        if ($this->compression) {
129 1
            $soapOptions['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP;
130
        }
131
132 2
        $soapOptions['cache_wsdl'] = $this->cache ? WSDL_CACHE_BOTH : WSDL_CACHE_NONE;
133
134 2
        return $soapOptions;
135
    }
136
}
137