Dispatcher::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
namespace PortlandLabs\Slackbot\Slack\Rtm\Event\Handler;
3
4
use PortlandLabs\Slackbot\Slack\Rtm\Event;
5
use PortlandLabs\Slackbot\Slack\Rtm\Event\Handler;
6
7
class Dispatcher implements Handler
8
{
9
10
    /** @var callable */
11
    protected $callback;
12
13
    public function __construct(callable $callback)
14
    {
15
        $this->callback = $callback;
16
    }
17
18
    /**
19
     * Handle an incoming event
20
     *
21
     * @param Event $event
22
     * @return Event
23
     */
24
    public function handle(Event $event): Event
25
    {
26
        $callback = $this->callback;
27
        $callback($event);
28
        return $event;
29
    }
30
}