Conditions | 2 |
Paths | 2 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
32 | 3 | public function newRouter() |
|
33 | { |
||
34 | 3 | $app = $this->getContainer()->get('app'); |
|
35 | |||
36 | /** @var Router $router */ |
||
37 | 3 | $router = $this->getContainer()->get( |
|
38 | 3 | RouterInterface::class, |
|
39 | [ |
||
40 | 3 | 'loader' => $this->getContainer()->get('routing.loader'), |
|
41 | 3 | 'resource' => 'routes.php', |
|
42 | 'options' => [ |
||
43 | 3 | 'cache_dir' => $app->getCachedRoutesPath(), |
|
44 | ] |
||
45 | ] |
||
46 | ); |
||
47 | |||
48 | 3 | $request = Request::instance(); |
|
49 | 3 | if ($request instanceof Request) { |
|
50 | 3 | $router->setContext((new RequestContext())->fromRequest($request)); |
|
51 | } |
||
52 | 3 | return $router; |
|
53 | } |
||
54 | } |
||
55 |
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.