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

HelperTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 52
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 27 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Skaut\Skautis;
5
6
use Skaut\Skautis\SessionAdapter\SessionAdapter;
7
use Skaut\Skautis\Wsdl\WebServiceFactory;
8
use Skaut\Skautis\Wsdl\WsdlManager;
9
10
trait HelperTrait
11
{
12
13
    /**
14
     * sigleton
15
     * @var Skautis[]
16
     */
17
    private static $instances = [];
18
19
20
21
    /**
22
     * Ziska sdilenou instanci Skautis objektu
23
     *
24
     * Ano vime ze to neni officialni pattern
25
     * Jedna se o kockopsa Mezi singletonem a StaticFactory
26
     * Factory metoda na stride kterou instantizuje a novy objekt vytvari jen 1x za beh
27
     * Proc to tak je? Ohled na zpetnou kompatibilitu a out of the box pouzitelnost pro amatery
28
     *
29
     * @var string $appId nastavení appId (nepovinné)
30
     * @var bool $testMode funguje v testovacím provozu? - výchozí je testovací mode (nepovinné)
31
     *
32
     * @return Skautis Sdilena instance Skautis knihovny pro cely beh PHP skriptu
33
     */
34 8
    public static function getInstance(
35
      string $appId,
36
      bool $testMode = Config::TEST_MODE_DISABLED,
37
      bool $cache = Config::CACHE_DISABLED,
38
      bool $compression = Config::COMPRESSION_DISABLED
39
    ): Skautis {
40 8
        $cacheKey = "$appId-$testMode";
41
42 8
        if (!isset(self::$instances[$cacheKey])) {
43 3
            $config = new Config(
44 3
              $appId,
45 3
              $testMode,
46 3
              $cache,
47 3
              $compression
48
            );
49 3
            $webServiceFactory = new WebServiceFactory();
50 3
            $wsdlManager = new WsdlManager($webServiceFactory, $config);
51
52
            // Out of box integrace s $_SESSION
53 3
            $sessionAdapter = new SessionAdapter();
54 3
            $user = new User($wsdlManager, $sessionAdapter);
55
56 3
            self::$instances[$cacheKey] = new Skautis($wsdlManager, $user);
57
        }
58
59 8
        return self::$instances[$cacheKey];
60
    }
61
}
62