| Conditions | 5 |
| Paths | 5 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 5.0061 |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | 2 | public function populateRequest() |
|
| 14 | { |
||
| 15 | 2 | $params = $this->getParams(); |
|
|
|
|||
| 16 | 2 | foreach ($params as $param => $value) { |
|
| 17 | switch ($param) { |
||
| 18 | 1 | case 'module': |
|
| 19 | 1 | $this->getRequest()->setModuleName($value); |
|
| 20 | 1 | break; |
|
| 21 | 1 | case 'controller': |
|
| 22 | 1 | $this->getRequest()->setControllerName($value); |
|
| 23 | 1 | break; |
|
| 24 | 1 | case 'action': |
|
| 25 | 1 | $this->getRequest()->setActionName($value); |
|
| 26 | 1 | break; |
|
| 27 | default: |
||
| 28 | $this->getRequest()->attributes->set($param, $value); |
||
| 29 | 1 | break; |
|
| 30 | } |
||
| 31 | } |
||
| 32 | 2 | $this->getRequest()->attributes->add($this->getMatches()); |
|
| 33 | 2 | } |
|
| 34 | |||
| 50 | } |
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
Idableprovides a methodequalsIdthat 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.