ApplicationStartEventListener   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 5
eloc 5
c 3
b 0
f 2
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A on() 0 7 3
A supports() 0 3 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\Console\Listener;
13
14
use Micro\Component\EventEmitter\EventInterface;
15
use Micro\Component\EventEmitter\EventListenerInterface;
16
use Micro\Kernel\App\Business\Event\ApplicationReadyEventInterface;
17
use Micro\Plugin\Console\Facade\ConsoleApplicationFacadeInterface;
18
19
class ApplicationStartEventListener implements EventListenerInterface
20
{
21 3
    public function __construct(
22
        private readonly ConsoleApplicationFacadeInterface $consoleApplicationFacade,
23
    ) {
24 3
    }
25
26
    /**
27
     * @param ApplicationReadyEventInterface $event
28
     *
29
     * @throws \Exception
30
     */
31 2
    public function on(EventInterface $event): void
32
    {
33 2
        if ('cli' !== $event->systemEnvironment() || \array_key_exists('RR_MODE', $_ENV)) {
0 ignored issues
show
Bug introduced by
The method systemEnvironment() does not exist on Micro\Component\EventEmitter\EventInterface. It seems like you code against a sub-type of Micro\Component\EventEmitter\EventInterface such as Micro\Kernel\App\Busines...tionReadyEventInterface. ( Ignorable by Annotation )

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

33
        if ('cli' !== $event->/** @scrutinizer ignore-call */ systemEnvironment() || \array_key_exists('RR_MODE', $_ENV)) {
Loading history...
34 1
            return;
35
        }
36
37 1
        $this->consoleApplicationFacade->run();
38
    }
39
40 1
    public static function supports(EventInterface $event): bool
41
    {
42 1
        return $event instanceof ApplicationReadyEventInterface;
43
    }
44
}
45