| Conditions | 11 |
| Paths | 22 |
| Total Lines | 38 |
| Code Lines | 22 |
| 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 |
||
| 87 | protected function attachRelatedPiecesAfterSave() |
||
| 88 | { |
||
| 89 | // remove any: |
||
| 90 | if (count($this->remove_on_event_names) > 0) { |
||
| 91 | $removePluginEvents = $this->xPDOSimpleObject->getMany('PluginEvents', ['event:IN' => $this->remove_on_event_names]); |
||
| 92 | /** @var \modPluginEvent $event */ |
||
| 93 | foreach ($removePluginEvents as $event) { |
||
| 94 | if (!$event->remove()) { |
||
| 95 | $this->blender->out('Plugin did not detach the event: '.$event->get('event')); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | $this->xPDOSimpleObject->save(); |
||
| 99 | } |
||
| 100 | |||
| 101 | if (count($this->related_data) > 0) { |
||
| 102 | foreach ($this->related_data as $event_data) { |
||
| 103 | if (in_array($event_data['event'], $this->remove_on_event_names)) { |
||
| 104 | continue; |
||
| 105 | } |
||
| 106 | |||
| 107 | // Does it already exist? |
||
| 108 | $pluginEvent = $this->modx->getObject('modPluginEvent', [ |
||
| 109 | 'event' => $event_data['event'], |
||
| 110 | 'pluginid' => $this->xPDOSimpleObject->get('id') |
||
| 111 | ]); |
||
| 112 | |||
| 113 | if (!$pluginEvent) { |
||
| 114 | $pluginEvent = $this->modx->newObject('modPluginEvent'); |
||
| 115 | $pluginEvent->set('event', $event_data['event']); |
||
| 116 | $pluginEvent->set('pluginid', $this->xPDOSimpleObject->get('id')); |
||
| 117 | } |
||
| 118 | |||
| 119 | $priority = (!empty($event_data['priority']) ? $event_data['priority'] : 0); |
||
| 120 | $pluginEvent->set('priority', (int)$priority); |
||
| 121 | $pluginEvent->set('propertyset', (int)(!empty($event_data['propertyset']) ? $event_data['propertyset'] : 0)); |
||
| 122 | |||
| 123 | if (!$pluginEvent->save()) { |
||
| 124 | $this->blender->out('Plugin did not attached the event: '.$event_data['event']); |
||
| 125 | } |
||
| 174 |
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