AbstractEmitEventProcessor::lookupEventEmitter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 8
ccs 2
cts 2
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\Kernel\App\Business\Processor;
13
14
use Micro\Component\DependencyInjection\Container;
15
use Micro\Component\EventEmitter\EventInterface;
16
use Micro\Kernel\App\AppKernelInterface;
17
use Micro\Kernel\App\Business\KernelActionProcessorInterface;
18
use Micro\Plugin\EventEmitter\EventsFacadeInterface;
19
20
abstract class AbstractEmitEventProcessor implements KernelActionProcessorInterface
21
{
22
    /**
23
     * {@inheritDoc}
24
     */
25 8
    public function process(AppKernelInterface $appKernel): void
26
    {
27 8
        $event = $this->createEvent($appKernel);
28
29 8
        $this->lookupEventEmitter($appKernel->container())->emit($event);
30
    }
31
32
    abstract protected function createEvent(AppKernelInterface $appKernel): EventInterface;
33
34
    /**
35
     * @throws \Psr\Container\ContainerExceptionInterface
36
     * @throws \Psr\Container\NotFoundExceptionInterface
37
     *
38
     * @psalm-suppress MoreSpecificReturnType
39
     */
40 8
    protected function lookupEventEmitter(Container $container): EventsFacadeInterface
41
    {
42
        /**
43
         * @psalm-suppress LessSpecificReturnStatement
44
         *
45
         * @phpstan-ignore-next-line
46
         */
47 8
        return $container->get(EventsFacadeInterface::class);
48
    }
49
}
50