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.
Completed
Pull Request — master (#13)
by Jérémy
03:46 queued 01:53
created

EventTrait::on()

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\Routing\ControllerContainer;
6
7
trait EventTrait {
8
    /**
9
     * On event fired
10
     * @param  string   $event    
11
     * @param  callable $callback [description]
12
     * @return void
13
     */
14
    abstract function on($event, callable $callback);
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
15
16
    /**
17
     * Emit event
18
     * @param  string $event     
19
     * @param  array  $arguments 
20
     * @return void
21
     */
22
    abstract function emit($event, array $arguments = []);
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
23
24
    /**
25
     * Helper to listing to after event
26
     *
27
     * @param  Callable $callback
28
     * @return Void
29
     */
30
    public function after($callback)
31
    {
32
        if (is_string($callback)) {
33
            $callback = ControllerContainer::resolveController($callback);
34
        }
35
36
        $this->on('after', function ($request, $response) use (&$callback) {
37
            try {
38
                call_user_func_array($callback, func_get_args());
39
            } catch (\Exception $e) {
40
                $this->emit('error', [$request, $response, $e->getMessage()]);
41
            }
42
        });
43
    }
44
}