Passed
Push — master ( 1c1894...5fa9ec )
by Stanislau
01:16 queued 12s
created

ApplicationStartedListener::isHttp()   A

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
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Http\Listener;
15
16
use Micro\Component\EventEmitter\EventInterface;
17
use Micro\Component\EventEmitter\EventListenerInterface;
18
use Micro\Kernel\App\Business\Event\ApplicationReadyEvent;
19
use Micro\Kernel\App\Business\Event\ApplicationReadyEventInterface;
20
use Micro\Plugin\Http\Facade\HttpFacadeInterface;
21
use Symfony\Component\HttpFoundation\Request;
22
23
/**
24
 * @author Stanislau Komar <[email protected]>
25
 */
26
class ApplicationStartedListener implements EventListenerInterface
27
{
28 3
    public function __construct(
29
        private readonly HttpFacadeInterface $httpFacade
30
    ) {
31 3
    }
32
33
    /**
34
     * @param ApplicationReadyEvent $event
35
     *
36
     * @psalm-suppress MoreSpecificImplementedParamType
37
     */
38 2
    public function on(EventInterface $event): void
39
    {
40 2
        $sysenv = $event->systemEnvironment();
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

40
        /** @scrutinizer ignore-call */ 
41
        $sysenv = $event->systemEnvironment();
Loading history...
41 2
        if ('cli' === $sysenv) {
42 1
            return;
43
        }
44
45 1
        $request = Request::createFromGlobals();
46
47 1
        $this->httpFacade->execute($request);
48
    }
49
50 1
    public static function supports(EventInterface $event): bool
51
    {
52 1
        return $event instanceof ApplicationReadyEventInterface;
53
    }
54
}
55