| Conditions | 3 |
| Paths | 3 |
| Total Lines | 53 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 13 | public function loadAction() |
||
| 14 | { |
||
| 15 | $sessionID = $this->Request()->getParam('session'); |
||
| 16 | $step = (int)$this->Request()->getParam('step', 1); |
||
| 17 | |||
| 18 | if (empty($sessionID)) { |
||
| 19 | throw new \Exception( |
||
| 20 | 'A valid session ID must be provided' |
||
| 21 | ); |
||
| 22 | } |
||
| 23 | |||
| 24 | $sqlParams = [ |
||
| 25 | ':sessionID' => $sessionID, |
||
| 26 | ':step' => $step, |
||
| 27 | ]; |
||
| 28 | |||
| 29 | $snapshot = $this->get('dbal_connection')->fetchAssoc( |
||
| 30 | 'SELECT * FROM `view_snapshots` WHERE `sessionID` = :sessionID AND `step` = :step', |
||
| 31 | $sqlParams |
||
| 32 | ); |
||
| 33 | |||
| 34 | if (empty($snapshot)) { |
||
| 35 | throw new \Exception( |
||
| 36 | sprintf('No snapshot found by session ID %s and step %d', $sessionID, $step) |
||
| 37 | ); |
||
| 38 | } |
||
| 39 | |||
| 40 | $nextStep = (int)$this->get('dbal_connection')->fetchColumn( |
||
| 41 | 'SELECT MIN(`step`) as step FROM `view_snapshots` WHERE `sessionID` = :sessionID AND `step` > :step LIMIT 1', |
||
| 42 | $sqlParams |
||
| 43 | ); |
||
| 44 | |||
| 45 | $prevStep = (int)$this->get('dbal_connection')->fetchColumn( |
||
| 46 | 'SELECT MAX(`step`) as step FROM `view_snapshots` WHERE `sessionID` = :sessionID AND `step` < :step LIMIT 1', |
||
| 47 | $sqlParams |
||
| 48 | ); |
||
| 49 | |||
| 50 | $params = json_decode($snapshot['params'], true); |
||
| 51 | |||
| 52 | $this->Request()->setParams($params); |
||
| 53 | |||
| 54 | $this->Request()->setControllerName($params['__controller']); |
||
| 55 | $this->Request()->setActionName($params['__action']); |
||
| 56 | |||
| 57 | $this->View()->loadTemplate($snapshot['template']); |
||
| 58 | $this->View()->assign(unserialize($snapshot['variables'])); |
||
| 59 | |||
| 60 | $this->View()->assign( |
||
| 61 | [ |
||
| 62 | 'snapshotStep' => $step, |
||
| 63 | 'snapshotNextStep' => $nextStep, |
||
| 64 | 'snapshotPrevStep' => $prevStep, |
||
| 65 | 'snapshotSessionID' => $sessionID, |
||
| 66 | ] |
||
| 93 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths