Conditions | 4 |
Paths | 6 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
19 | 3 | public function route($request) |
|
20 | { |
||
21 | 3 | $current = false; |
|
22 | 3 | $uri = $request->path(); |
|
23 | 3 | $routes = $this->getRoutes(); |
|
|
|||
24 | |||
25 | 3 | foreach ($routes as $name => $route) { |
|
26 | 2 | $route->setRequest($request); |
|
27 | 2 | if ($route->match($uri)) { |
|
28 | 2 | $current = $route; |
|
29 | 2 | break; |
|
30 | } |
||
31 | } |
||
32 | |||
33 | 3 | if ($current instanceof Route) { |
|
34 | 2 | $this->setCurrent($current); |
|
35 | 2 | $current->populateRequest(); |
|
36 | |||
37 | 2 | return $current->getParams() + $current->getMatches(); |
|
38 | } else { |
||
39 | 2 | return []; |
|
40 | } |
||
41 | } |
||
42 | |||
43 | } |
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
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. 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.