ServiceContainerLauncher   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 10
c 1
b 0
f 0
dl 0
loc 29
ccs 0
cts 12
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A maybeAddProviders() 0 5 3
A __construct() 0 3 1
A maybeBootProviders() 0 4 2
A maybeAddServices() 0 4 2
1
<?php
2
3
namespace Panamax;
4
5
use Panamax\Contracts\BootableProviderContainerInterface;
6
use Panamax\Contracts\ProviderContainerInterface;
7
use Panamax\Contracts\ServiceContainerInterface;
8
use Panamax\Contracts\ServiceContainerLauncherInterface;
9
use Panamax\Contracts\ServiceCreatorInterface;
10
11
class ServiceContainerLauncher implements ServiceContainerLauncherInterface
12
{
13
    protected ServiceContainerInterface $container;
14
15
    public function __construct(ServiceContainerInterface $container)
16
    {
17
        $this->container = $container;
18
    }
19
20
    public function maybeAddServices(iterable $services)
21
    {
22
        if ($this->container instanceof ServiceCreatorInterface) {
23
            $this->container->createServices($services);
0 ignored issues
show
Bug introduced by
The method createServices() does not exist on Panamax\Contracts\ServiceContainerInterface. It seems like you code against a sub-type of Panamax\Contracts\ServiceContainerInterface such as Panamax\Adapters\League\LeagueAdapter or Panamax\Adapters\League\LeagueAdapter or Panamax\Adapters\League\LeagueAdapter. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
            $this->container->/** @scrutinizer ignore-call */ 
24
                              createServices($services);
Loading history...
24
        }
25
    }
26
27
    public function maybeAddProviders(iterable $providers)
28
    {
29
        if ($this->container instanceof ProviderContainerInterface) {
30
            foreach ($providers as $provider) {
31
                $this->container->addServiceProvider($provider);
0 ignored issues
show
Bug introduced by
The method addServiceProvider() does not exist on Panamax\Contracts\ServiceContainerInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Panamax\Contracts\ContainerAdapterInterface or Panamax\Adapters\AbstractContainerAdapter. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
                $this->container->/** @scrutinizer ignore-call */ 
32
                                  addServiceProvider($provider);
Loading history...
32
            }
33
        }
34
    }
35
36
    public function maybeBootProviders()
37
    {
38
        if ($this->container instanceof BootableProviderContainerInterface) {
39
            $this->container->bootServiceProviders();
0 ignored issues
show
Bug introduced by
The method bootServiceProviders() does not exist on Panamax\Contracts\ServiceContainerInterface. It seems like you code against a sub-type of Panamax\Contracts\ServiceContainerInterface such as Panamax\Contracts\Bootab...viderContainerInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
            $this->container->/** @scrutinizer ignore-call */ 
40
                              bootServiceProviders();
Loading history...
40
        }
41
    }
42
}
43