ServiceContainerLauncher::maybeAddProviders()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
cc 3
nc 3
nop 1
crap 12
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