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

DelayedCallable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 35
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onDelayedCallable() 0 4 1
A onRequestEnded() 0 7 2
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