Dispatcher   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 5 1
A __construct() 0 3 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
}