| Conditions | 8 |
| Paths | 4 |
| Total Lines | 66 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 51 | public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs $args) |
||
| 52 | { |
||
| 53 | $view = $args->getSubject()->View(); |
||
| 54 | $request = $args->getSubject()->Request(); |
||
| 55 | $params = $request->getParams(); |
||
| 56 | $sessionID = $this->session->get('sessionId'); |
||
| 57 | |||
| 58 | $isSessionRecorded = strtolower($request->getControllerName()) !== 'snapshots' ? |
||
| 59 | $this->session->get('isSessionRecorded') : |
||
| 60 | false; |
||
| 61 | |||
| 62 | $snapshotSessionID = $view->getAssign('snapshotSessionID'); |
||
| 63 | |||
| 64 | $view->assign( |
||
| 65 | [ |
||
| 66 | 'snapshotSessionID' => $snapshotSessionID ? : $sessionID, |
||
| 67 | 'isSessionRecorded' => $isSessionRecorded, |
||
| 68 | ] |
||
| 69 | ); |
||
| 70 | |||
| 71 | if ( |
||
| 72 | $snapshotSessionID || |
||
| 73 | !$isSessionRecorded || |
||
| 74 | $request->isXmlHttpRequest() |
||
| 75 | ) |
||
| 76 | { |
||
| 77 | return; |
||
| 78 | } |
||
| 79 | |||
| 80 | $template = $view->Template()->template_resource; |
||
| 81 | |||
| 82 | $variables = $view->getAssign(); |
||
| 83 | |||
| 84 | array_walk_recursive($variables, function (&$value) { |
||
| 85 | if (is_object($value)) { |
||
| 86 | try { |
||
| 87 | // workaround for PDOException when trying to serialize PDO instances |
||
| 88 | serialize($value); |
||
| 89 | } |
||
| 90 | catch (\Throwable $e) { |
||
| 91 | // as we only need a snapshot for the view, remove the PDO instance |
||
| 92 | $value = null; |
||
| 93 | } |
||
| 94 | } |
||
| 95 | }); |
||
| 96 | |||
| 97 | $variables = serialize($variables); |
||
| 98 | |||
| 99 | $params['__controller'] = $request->getControllerName(); |
||
| 100 | $params['__action'] = $request->getActionName(); |
||
| 101 | $params = json_encode($params); |
||
| 102 | |||
| 103 | $step = (int)$this->connection->fetchColumn( |
||
| 104 | 'SELECT MAX(`step`) FROM `view_snapshots` WHERE `sessionID` = :sessionID', |
||
| 105 | ['sessionID' => $sessionID] |
||
| 106 | ); |
||
| 107 | $step++; |
||
| 108 | |||
| 109 | $this->connection->insert( |
||
| 110 | 'view_snapshots', |
||
| 111 | [ |
||
| 112 | 'sessionID' => $sessionID, |
||
| 113 | 'template' => $template, |
||
| 114 | 'variables' => $variables, |
||
| 115 | 'params' => $params, |
||
| 116 | 'step' => $step, |
||
| 117 | ] |
||
| 120 | } |
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