EventEmitterPlugin::createFacade()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
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\EventEmitter;
13
14
use Micro\Component\DependencyInjection\Autowire\AutowireHelperInterface;
15
use Micro\Component\DependencyInjection\Container;
16
use Micro\Component\EventEmitter\EventEmitterFactoryInterface;
17
use Micro\Framework\Kernel\Plugin\DependencyProviderInterface;
18
use Micro\Plugin\EventEmitter\Business\Facade\EventsFacade;
19
use Micro\Plugin\EventEmitter\Business\Factory\EventEmitterFactory;
20
use Micro\Plugin\EventEmitter\Business\Locator\EventListenerClassLocatorFactory;
21
use Micro\Plugin\EventEmitter\Business\Locator\EventListenerClassLocatorFactoryInterface;
22
use Micro\Plugin\EventEmitter\Business\Provider\ProviderFactory;
23
use Micro\Plugin\EventEmitter\Business\Provider\ProviderFactoryInterface;
24
use Micro\Plugin\Locator\Facade\LocatorFacadeInterface;
25
26
class EventEmitterPlugin implements DependencyProviderInterface
27
{
28
    private LocatorFacadeInterface $locatorFacade;
29
30
    private AutowireHelperInterface $autowireHelper;
31
32
    /**
33
     * {@inheritDoc}
34
     */
35 1
    public function provideDependencies(Container $container): void
36
    {
37 1
        $container->register(EventsFacadeInterface::class, function (
38 1
            AutowireHelperInterface $autowireHelper,
39 1
            LocatorFacadeInterface $locatorFacade,
40 1
        ): EventsFacadeInterface {
41 1
            $this->locatorFacade = $locatorFacade;
42 1
            $this->autowireHelper = $autowireHelper;
43
44 1
            return $this->createFacade();
45 1
        });
46
    }
47
48 1
    protected function createFacade(): EventsFacadeInterface
49
    {
50 1
        return new EventsFacade($this->createEventEmitterFactory());
51
    }
52
53 1
    protected function createEventEmitterFactory(): EventEmitterFactoryInterface
54
    {
55 1
        return new EventEmitterFactory(
56 1
            $this->createProviderFactory()
57 1
        );
58
    }
59
60 1
    protected function createProviderFactory(): ProviderFactoryInterface
61
    {
62 1
        return new ProviderFactory(
63 1
            $this->autowireHelper,
64 1
            $this->createEventListenerClassLocatorFactory(),
65 1
        );
66
    }
67
68 1
    protected function createEventListenerClassLocatorFactory(): EventListenerClassLocatorFactoryInterface
69
    {
70 1
        return new EventListenerClassLocatorFactory(
71 1
            $this->locatorFacade
72 1
        );
73
    }
74
}
75