Completed
Push — master ( 97f6b5...9ef69c )
by Matze
08:25
created

DelayedCallable::onRequestEnded()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
3
namespace BrainExe\Core\EventDispatcher;
4
5
use BrainExe\Core\Annotations\Listen;
6
use BrainExe\Core\Annotations\Service;
7
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
8
9
/**
10
 * @Service
11
 */
12
class DelayedCallable
13
{
14
15
    const FINISHED_EVENT = 'request.finished';
16
17
    /**
18
     * @var callable[]
19
     */
20
    private $delayed = [];
21
22
    /**
23
     * @Listen(DelayedCallableEvent::DELAYED)
24
     *
25
     * @param DelayedCallableEvent $event
26
     */
27
    public function onDelayedCallable(DelayedCallableEvent $event): void
28
    {
29
        $this->delayed[] = $event->getCallable();
30
    }
31
32
    /**
33
     * @Listen(DelayedCallable::FINISHED_EVENT);
34
     *
35
     * @param FinishRequestEvent $event
36
     */
37
    public function onRequestEnded(FinishRequestEvent $event): void
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39
        foreach ($this->delayed as $callable) {
40
            $callable();
41
        }
42
        $this->delayed = [];
43
    }
44
45
46
}
47