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 ( 48a2e9...c23789 )
by Jindřich
20s queued 11s
created

WebServiceFactory::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
crap 2.0185
rs 9.9
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Skaut\Skautis\Wsdl;
5
6
use Psr\EventDispatcher\EventDispatcherInterface;
7
use Skaut\Skautis\InvalidArgumentException;
8
9
final class WebServiceFactory implements WebServiceFactoryInterface
10
{
11
12
    /**
13
     * @var string Třída webové služby
14
     */
15
    private $class;
16
17
    /**
18
     * @var EventDispatcherInterface|null
19
     */
20
    private $eventDispatcher;
21
22
23
    /**
24
     * @param string $className Constructor must accept SoapClient, SOAP options array and EventDispatcherInterface
25
     */
26 5
    public function __construct(
27
      string $className = WebService::class,
28
      ?EventDispatcherInterface $eventDispatcher = null
29
    ) {
30 5
        if (!is_a($className, WebServiceInterface::class, true)) {
31
          throw new InvalidArgumentException("Argument must be class name of a class implementing WebServiceInterface. '$className' given");
32
        }
33
34 5
        $this->class = $className;
35 5
        $this->eventDispatcher = $eventDispatcher;
36 5
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41 3
    public function createWebService(string $url, array $options): WebServiceInterface
42
    {
43 3
        if (empty($url)) {
44 1
          throw new InvalidArgumentException('WSDL URL cannot be empty.');
45
        }
46
47 2
        $soapClient = new \SoapClient($url, $options);
48 2
        return new $this->class($soapClient, $options, $this->eventDispatcher);
49
    }
50
}
51