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   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 37
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
on() 0 1 ?
emit() 0 1 ?
A after() 0 12 2
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
}