LocatorPlugin::createLocatorFacade()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 2
b 0
f 0
1
<?php
2
3
/*
4
 *  This file is part of the Micro framework package.
5
 *
6
 *  (c) Stanislau Komar <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace Micro\Plugin\Locator;
13
14
use Micro\Component\DependencyInjection\Container;
15
use Micro\Framework\Kernel\KernelInterface;
16
use Micro\Framework\Kernel\Plugin\DependencyProviderInterface;
17
use Micro\Plugin\Locator\Facade\LocatorFacade;
18
use Micro\Plugin\Locator\Facade\LocatorFacadeInterface;
19
use Micro\Plugin\Locator\Locator\LocatorFactory;
20
use Micro\Plugin\Locator\Locator\LocatorFactoryInterface;
21
22
class LocatorPlugin implements DependencyProviderInterface
23
{
24
    private ?KernelInterface $kernel = null;
25
26
    /**
27
     * {@inheritDoc}
28
     */
29 1
    public function provideDependencies(Container $container): void
30
    {
31 1
        $container->register(LocatorFacadeInterface::class, function (
32 1
            KernelInterface $kernel
33 1
        ) {
34 1
            $this->kernel = $kernel;
35
36 1
            return $this->createLocatorFacade();
37 1
        });
38
    }
39
40 1
    protected function createLocatorFacade(): LocatorFacadeInterface
41
    {
42 1
        return new LocatorFacade(
43 1
            $this->createLocatorFactory()
44 1
        );
45
    }
46
47 1
    protected function createLocatorFactory(): LocatorFactoryInterface
48
    {
49 1
        return new LocatorFactory($this->kernel);
0 ignored issues
show
Bug introduced by
It seems like $this->kernel can also be of type null; however, parameter $kernel of Micro\Plugin\Locator\Loc...rFactory::__construct() does only seem to accept Micro\Framework\Kernel\KernelInterface, maybe add an additional type check? ( Ignorable by Annotation )

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

49
        return new LocatorFactory(/** @scrutinizer ignore-type */ $this->kernel);
Loading history...
50
    }
51
}
52