GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

EventTrait::on()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 1
nc 1
1
<?php
2
3
namespace CapMousse\ReactRestify\Traits;
4
5
use CapMousse\ReactRestify\Container\Container;
6
7
trait EventTrait
8
{
9
    /**
10
     * On event fired
11
     * @param  string   $event    
12
     * @param  callable $callback [description]
13
     * @return void
14
     */
15
    abstract public function on($event, callable $callback);
16
17
    /**
18
     * Emit event
19
     * @param  string $event     
20
     * @param  array  $arguments 
21
     * @return void
22
     */
23
    abstract public function emit($event, array $arguments = []);
24
25
    /**
26
     * Helper to listing to after event
27
     *
28
     * @param  Callable $callback
29
     * @return Void
30
     */
31
    public function after($callback)
32
    {
33
        $container  = Container::getInstance();
34
35
        $this->on('after', function ($request, $response) use (&$container, &$callback) {
36
            try {
37
                $container->call($callback, func_get_args());
38
            } catch (\Exception $e) {
39
                $this->emit('error', [$request, $response, $e->getMessage()]);
40
            }
41
        });
42
    }
43
}