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.
Test Setup Failed
Push — master ( fe4962...3aa77f )
by Thijs
04:04
created

SoapSettings::getFeatures()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace WebservicesNl\Protocol\Soap\Client;
4
5
use WebservicesNl\Common\Exception\Client\InputException;
6
7
/**
8
 * Class SoapSettings.
9
 *
10
 * Container for all the SoapClient settings. For HTTP authentication, the login and password options can be used to
11
 * supply credentials. For making an HTTP connection through a proxy server, the options are:
12
 *  - proxy_host
13
 *  - proxy_port
14
 *  - proxy_login
15
 *  - proxy_password
16
 *
17
 *  For HTTPS client certificate authentication use local_cert and passphrase options
18
 *
19
 * @link http://php.net/manual/en/soapclient.soapclient.php
20
 */
21
class SoapSettings
22
{
23
    const DEFAULT_CONNECTION_TIMEOUT = 5;
24
    const USER_AGENT = 'WebservicesNlSoapClient/PHP/2.0';
25
26
    /**
27
     * An authentication may be supplied in the authentication option.
28
     * The authentication method may be either SOAP_AUTHENTICATION_BASIC (default) or SOAP_AUTHENTICATION_DIGEST.
29
     *
30
     * @var int
31
     */
32
    private $authentication = SOAP_AUTHENTICATION_BASIC;
33
34
    /**
35
     * The cache_wsdl option is one of WSDL_CACHE_NONE, WSDL_CACHE_DISK, WSDL_CACHE_MEMORY or WSDL_CACHE_BOTH.
36
     *
37
     * @var int
38
     */
39
    private $cacheWsdl = WSDL_CACHE_NONE;
40
41
    /**
42
     * Optional Class map.
43
     *
44
     * @var array | null
45
     */
46
    private $classMap;
47
48
    /**
49
     * The compression option allows to use compression of HTTP SOAP requests and responses.
50
     *
51
     * @var int
52
     */
53
    private $compression = SOAP_COMPRESSION_ACCEPT;
54
55
    /**
56
     * The connection_timeout option defines a timeout in seconds for the connection to the SOAP service.
57
     *
58
     * This option does not define a timeout for services with slow responses. To limit the time to wait for calls to
59
     * finish the default_socket_timeout setting is available.
60
     *
61
     * @var int
62
     */
63
    private $connectionTimeout = self::DEFAULT_CONNECTION_TIMEOUT;
64
65
    /**
66
     * The stream_context option is a resource for context.
67
     *
68
     * @var resource
69
     */
70
    private $context;
71
72
    /**
73
     * The encoding option defines internal character encoding.
74
     * This option does not change the encoding of SOAP requests (it is always utf-8), but converts strings into it.
75
     *
76
     * @var
77
     */
78
    private $encoding = 'UTF-8';
79
80
    /**
81
     * The exceptions option is a boolean value defining whether soap errors throw exceptions of type SoapFault.
82
     *
83
     * @var bool
84
     */
85
    private $exceptions = true;
86
87
    /**
88
     * The features option is a bitmask of SOAP_SINGLE_ELEMENT_ARRAYS, SOAP_USE_XSI_ARRAY_TYPE, SOAP_WAIT_ONE_WAY_CALLS.
89
     *
90
     * @var int
91
     */
92
    private $features = SOAP_SINGLE_ELEMENT_ARRAYS;
93
94
    /**
95
     * Optional value defining whether to send the Connection: 'Keep-Alive' or Connection: 'close'.
96
     *
97
     * @var bool
98
     */
99
    private $keepAlive = true;
100
101
    /**
102
     * login username for HTTP Authentication. (optional).
103
     *
104
     * @var string
105
     */
106
    private $login;
107
108
    /**
109
     * path to cert_key.pem.
110
     *
111
     * @var string
112
     */
113
    private $localCert;
114
115
    /**
116
     * Passphrase for localCert pem.
117
     *
118
     * @var string
119
     */
120
    private $passphrase;
121
122
    /**
123
     * @var string
124
     */
125
    private $password;
126
127
    /**
128
     * @var string
129
     */
130
    private $proxyHost;
131
132
    /**
133
     * @var string
134
     */
135
    private $proxyLogin;
136
    /**
137
     * @var string
138
     */
139
    private $proxyPassword;
140
141
    /**
142
     * @var string
143
     */
144
    private $proxyPort;
145
146
    /**
147
     * All possible SOAP SSL methods.
148
     *
149
     * @var array
150
     */
151
    public static $sslMethods =
152
        [
153
            SOAP_SSL_METHOD_TLS,
154
            SOAP_SSL_METHOD_SSLv2,
155
            SOAP_SSL_METHOD_SSLv3,
156
            SOAP_SSL_METHOD_SSLv23,
157
        ];
158
159
    /**
160
     * The ssl_method option is one of SOAP_SSL_METHOD_TLS, SOAP_SSL_METHOD_SSLv2, SOAP_SSL_METHOD_SSLv3 or
161
     * SOAP_SSL_METHOD_SSLv23.
162
     *
163
     * (Only PHP 5.5+)
164
     *
165
     */
166
    private $sslMethod = SOAP_SSL_METHOD_SSLv23;
167
168
    /**
169
     * @var array|null
170
     *                 The typemap option is an array of type mappings.
171
     *                 Type mapping is an array with keys type_name, type_ns (namespace URI),
172
     *                 from_xml (callback accepting one string parameter) and to_xml
173
     *                 (callback accepting one object parameter).
174
     *
175
     * Example array("type_ns"   => "http://schemas.nothing.com",
176
     *               "type_name" => "book",
177
     *               "from_xml"  => "some_function_name" callback accepting one string parameter
178
     *               "to_xml"    => "some_function_name" callback accepting one string parameter")
179
     */
180
    private $typeMap;
181
182
    /**
183
     * Soap Version (either SOAP_1_1 or SOAP_1_2).
184
     *
185
     * @var int
186
     */
187
    private $soapVersion = SOAP_1_1;
188
189
    /**
190
     * Must be set in non-WSDL mode.
191
     *
192
     * @var string
193
     */
194
    private $uri;
195
196
    /**
197
     * The user_agent option specifies string to use in User-Agent header.
198
     *
199
     * @var string
200
     */
201
    private $userAgent = self::USER_AGENT;
202
203
    /**
204
     * Load config object from array.
205
     *
206
     * @param array $options
207
     *
208
     * @return SoapSettings
209
     */
210
    public static function loadFromArray(array $options)
211
    {
212
        $options = array_filter($options);
213
        $config = new static();
214
        foreach ($options as $key => $value) {
215
            $name = 'set' . ucfirst(strtolower($key));
216
            if (method_exists($config, $name)) {
217
                $config->{$name}($value);
218
            }
219
        }
220
221
        return $config;
222
    }
223
224
    /**
225
     * Return the Authentication flag
226
     *
227
     * @return int
228
     */
229
    public function getAuthentication()
230
    {
231
        return $this->authentication;
232
    }
233
234
    /**
235
     * Set the authentication flag
236
     *
237
     * @param int $authentication
238
     *
239
     * @return SoapSettings
240
     */
241
    public function setAuthentication($authentication)
242
    {
243
        $this->authentication = $authentication;
244
245
        return $this;
246
    }
247
248
    /**
249
     * Return the Cache WSDL bitflag
250
     *
251
     * @return int
252
     */
253
    public function getCacheWsdl()
254
    {
255
        return $this->cacheWsdl;
256
    }
257
258
    /**
259
     * @param int $cacheWsdl
260
     *
261
     * @return SoapSettings
262
     */
263
    public function setCacheWsdl($cacheWsdl)
264
    {
265
        $this->cacheWsdl = $cacheWsdl;
266
267
        return $this;
268
    }
269
270
    /**
271
     * Returns class mapping.
272
     *
273
     * @return array|null
274
     */
275
    public function getClassMap()
276
    {
277
        return $this->classMap;
278
    }
279
280
    /**
281
     * @param array $classMap
282
     *
283
     * @return SoapSettings
284
     */
285
    public function setClassMap($classMap)
286
    {
287
        $this->classMap = $classMap;
288
289
        return $this;
290
    }
291
292
    /**
293
     * Return Compression flag
294
     *
295
     * @return int
296
     */
297
    public function getCompression()
298
    {
299
        return $this->compression;
300
    }
301
302
    /**
303
     * @param int $compression
304
     *
305
     * @return SoapSettings
306
     */
307
    public function setCompression($compression)
308
    {
309
        if (in_array($compression, [SOAP_COMPRESSION_ACCEPT, SOAP_COMPRESSION_GZIP, SOAP_COMPRESSION_DEFLATE], true)) {
310
            $this->compression = $compression;
311
        }
312
313
        return $this;
314
    }
315
316
    /**
317
     * @return int
318
     */
319
    public function getConnectionTimeout()
320
    {
321
        return $this->connectionTimeout;
322
    }
323
324
    /**
325
     * @param int $connectionTimeout
326
     *
327
     * @return SoapSettings
328
     *
329
     * @throws InputException
330
     */
331
    public function setConnectionTimeout($connectionTimeout)
332
    {
333
        if (!is_int($connectionTimeout)) {
334
            throw new InputException('Not a valid timeout');
335
        }
336
        $this->connectionTimeout = $connectionTimeout;
337
338
        return $this;
339
    }
340
341
    /**
342
     * @return resource
343
     */
344
    public function getContext()
345
    {
346
        return $this->context;
347
    }
348
349
    /**
350
     * @param resource $context
351
     *
352
     * @return SoapSettings
353
     */
354
    public function setContext($context)
355
    {
356
        $this->context = $context;
357
358
        return $this;
359
    }
360
361
    /**
362
     * @return mixed
363
     */
364
    public function getEncoding()
365
    {
366
        return $this->encoding;
367
    }
368
369
    /**
370
     * @param mixed $encoding
371
     *
372
     * @return SoapSettings
373
     */
374
    public function setEncoding($encoding)
375
    {
376
        $this->encoding = $encoding;
377
378
        return $this;
379
    }
380
381
    /**
382
     * @return bool
383
     */
384
    public function hasExceptions()
385
    {
386
        return $this->exceptions;
387
    }
388
389
    /**
390
     * @param bool $exceptions
391
     *
392
     * @return SoapSettings
393
     */
394
    public function setExceptions($exceptions)
395
    {
396
        $this->exceptions = $exceptions;
397
398
        return $this;
399
    }
400
401
    /**
402
     * @return int
403
     */
404
    public function getFeatures()
405
    {
406
        return $this->features;
407
    }
408
409
    /**
410
     * Set SoapFeatures bitmask.
411
     *
412
     * @param int $features
413
     *
414
     * @return SoapSettings
415
     */
416
    public function setFeatures($features)
417
    {
418
        if (in_array($features, [SOAP_SINGLE_ELEMENT_ARRAYS, SOAP_USE_XSI_ARRAY_TYPE, SOAP_WAIT_ONE_WAY_CALLS], true)) {
419
            $this->features |= $features;
420
        }
421
422
        return $this;
423
    }
424
425
    /**
426
     * @return bool
427
     */
428
    public function isKeepAlive()
429
    {
430
        return $this->keepAlive;
431
    }
432
433
    /**
434
     * @param bool $keepAlive
435
     *
436
     * @return SoapSettings
437
     */
438
    public function setKeepAlive($keepAlive)
439
    {
440
        $this->keepAlive = $keepAlive;
441
442
        return $this;
443
    }
444
445
    /**
446
     * @return string
447
     */
448
    public function getLogin()
449
    {
450
        return $this->login;
451
    }
452
453
    /**
454
     * @return string
455
     */
456
    public function getLocalCert()
457
    {
458
        return $this->localCert;
459
    }
460
461
    /**
462
     * @param string $localCert
463
     *
464
     * @return SoapSettings
465
     */
466
    public function setLocalCert($localCert)
467
    {
468
        $this->localCert = $localCert;
469
470
        return $this;
471
    }
472
473
    /**
474
     * @return string
475
     */
476
    public function getPassphrase()
477
    {
478
        return $this->passphrase;
479
    }
480
481
    /**
482
     * @param string $login
483
     */
484
    public function setLogin($login)
485
    {
486
        $this->login = $login;
487
    }
488
489
    /**
490
     * @param string $passPhrase
491
     *
492
     * @return SoapSettings
493
     */
494
    public function setPassphrase($passPhrase)
495
    {
496
        $this->passphrase = $passPhrase;
497
498
        return $this;
499
    }
500
501
    /**
502
     * @return string
503
     */
504
    public function getPassword()
505
    {
506
        return $this->password;
507
    }
508
509
    /**
510
     * @param string $password
511
     *
512
     * @return SoapSettings
513
     */
514
    public function setPassword($password)
515
    {
516
        $this->password = $password;
517
518
        return $this;
519
    }
520
521
    /**
522
     * @return string
523
     */
524
    public function getProxyHost()
525
    {
526
        return $this->proxyHost;
527
    }
528
529
    /**
530
     * @param string $proxyHost
531
     *
532
     * @return SoapSettings
533
     */
534
    public function setProxyHost($proxyHost)
535
    {
536
        $this->proxyHost = $proxyHost;
537
538
        return $this;
539
    }
540
541
    /**
542
     * @return string
543
     */
544
    public function getProxyLogin()
545
    {
546
        return $this->proxyLogin;
547
    }
548
549
    /**
550
     * @param string $proxyLogin
551
     *
552
     * @return SoapSettings
553
     */
554
    public function setProxyLogin($proxyLogin)
555
    {
556
        $this->proxyLogin = $proxyLogin;
557
558
        return $this;
559
    }
560
561
    /**
562
     * @return string
563
     */
564
    public function getProxyPassword()
565
    {
566
        return $this->proxyPassword;
567
    }
568
569
    /**
570
     * @param string $proxyPassword
571
     *
572
     * @return SoapSettings
573
     */
574
    public function setProxyPassword($proxyPassword)
575
    {
576
        $this->proxyPassword = $proxyPassword;
577
578
        return $this;
579
    }
580
581
    /**
582
     * @return string
583
     */
584
    public function getProxyPort()
585
    {
586
        return $this->proxyPort;
587
    }
588
589
    /**
590
     * @param string $proxyPort
591
     *
592
     * @return SoapSettings
593
     */
594
    public function setProxyPort($proxyPort)
595
    {
596
        $this->proxyPort = $proxyPort;
597
598
        return $this;
599
    }
600
601
    /**
602
     * @return int
603
     */
604
    public function getSoapVersion()
605
    {
606
        return $this->soapVersion;
607
    }
608
609
    /**
610
     * Defaults to 1.
611
     *
612
     * @param int $soapVersion
613
     */
614
    public function setSoapVersion($soapVersion)
615
    {
616
        if (in_array($soapVersion, [SOAP_1_1, SOAP_1_2], false)) {
617
            $this->soapVersion = $soapVersion;
618
        }
619
    }
620
621
    /**
622
     * @return int
623
     */
624
    public function getSslMethod()
625
    {
626
        return $this->sslMethod;
627
    }
628
629
    /**
630
     * php 5.4+.
631
     *
632
     * @param int $sslMethod
633
     *
634
     * @return SoapSettings
635
     */
636
    public function setSslMethod($sslMethod)
637
    {
638
        if (PHP_VERSION_ID >= 50400 && in_array($sslMethod, self::$sslMethods, true)) {
639
            $this->sslMethod = $sslMethod;
640
        }
641
642
        return $this;
643
    }
644
645
    /**
646
     * @return array|null
647
     */
648
    public function getTypeMap()
649
    {
650
        return $this->typeMap;
651
    }
652
653
    /**
654
     * @param array|null $typeMap
655
     *
656
     * @return SoapSettings
657
     */
658
    public function setTypeMap($typeMap)
659
    {
660
        $this->typeMap = $typeMap;
661
662
        return $this;
663
    }
664
665
    /**
666
     * @return string
667
     */
668
    public function getUri()
669
    {
670
        return $this->uri;
671
    }
672
673
    /**
674
     * @param string $uri
675
     *
676
     * @return SoapSettings
677
     */
678
    public function setUri($uri)
679
    {
680
        $this->uri = $uri;
681
682
        return $this;
683
    }
684
685
    /**
686
     * @return string
687
     */
688
    public function getUserAgent()
689
    {
690
        return $this->userAgent;
691
    }
692
693
    /**
694
     * @param string $userAgent
695
     *
696
     * @return SoapSettings
697
     */
698
    public function setUserAgent($userAgent)
699
    {
700
        $this->userAgent = $userAgent;
701
702
        return $this;
703
    }
704
705
    /**
706
     * @return array
707
     */
708
    public function toArray()
709
    {
710
        return get_object_vars($this);
711
    }
712
}
713