Conditions | 5 |
Paths | 5 |
Total Lines | 19 |
Lines | 19 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
33 | View Code Duplication | protected function populateRequest($request, $params) |
|
34 | { |
||
35 | foreach ($params as $param => $value) { |
||
36 | switch ($param) { |
||
37 | case 'module': |
||
38 | $request->setModuleName($value); |
||
39 | break; |
||
40 | case 'controller': |
||
41 | $request->setControllerName($value); |
||
42 | break; |
||
43 | case 'action': |
||
44 | $request->setActionName($value); |
||
45 | break; |
||
46 | default: |
||
47 | $request->attributes->set($param, $value); |
||
48 | break; |
||
49 | } |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 |
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.