Passed
Pull Request — master (#10)
by Alice
02:01
created

TestListener   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A onTestEvent() 0 3 1
A onTickRemoved() 0 3 1
A getEventMapping() 0 5 1
1
<?php
2
3
namespace Wonderland\Thread\Example\Simple;
4
5
6
use Wonderland\Thread\Event\PoolEvent;
7
use Wonderland\Thread\Mediator\Listener\AbstractListener;
8
9
class TestListener extends AbstractListener
10
{
11
    /**
12
     * @return array
13
     */
14
    public function getEventMapping(): array
15
    {
16
        return [
17
            PoolEvent::POOL_WAIT_TICK_PID_REMOVED => 'onTickRemoved',
18
            TestEvent::EVENT_NAME => 'onTestEvent'
19
        ];
20
    }
21
22
    /**
23
     * @param PoolEvent $event
24
     */
25
    public function onTickRemoved(PoolEvent $event)
26
    {
27
        echo $event->getThreadLeftNb() . PHP_EOL;
28
    }
29
30
    /**
31
     * @param TestEvent $event
32
     */
33
    public function onTestEvent(TestEvent $event)
34
    {
35
        echo $event->getEventParam() . PHP_EOL;
36
    }
37
}