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:43 queued 01:52
created

EventTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A after() 0 14 3
1
<?php
2
3
namespace CapMousse\ReactRestify\Traits;
4
5
use CapMousse\ReactRestify\Routing\ControllerContainer;
6
7
trait EventTrait {
8
9
    /**
10
     * Helper to listing to after event
11
     *
12
     * @param  Callable $callback
13
     * @return Void
14
     */
15
    public function after($callback)
16
    {
17
        if (is_string($callback)) {
18
            $callback = ControllerContainer::resolveController($callback);
19
        }
20
21
        $this->on('after', function ($request, $response) use (&$callback) {
0 ignored issues
show
Bug introduced by
It seems like on() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
22
            try {
23
                call_user_func_array($callback, func_get_args());
24
            } catch (\Execption $e) {
0 ignored issues
show
Bug introduced by
The class Execption does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
25
                $this->emit('error', [$request, $response, $e->getMessage()]);
0 ignored issues
show
Bug introduced by
It seems like emit() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
26
            }
27
        });
28
    }
29
}