ApplicationStartEventListener::supports()   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 2
Bugs 0 Features 1
Metric Value
eloc 1
c 2
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
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\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