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