| Conditions | 7 |
| Paths | 8 |
| Total Lines | 57 |
| Code Lines | 41 |
| 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 |
||
| 79 | public function getEditForm($id = null, $fields = null) |
||
| 80 | { |
||
| 81 | $config = Setting::current_foxy_setting(); |
||
| 82 | $fields = $config->getCMSFields(); |
||
| 83 | // Tell the CMS what URL the preview should show |
||
| 84 | $home = Director::absoluteBaseURL(); |
||
| 85 | $fields->push(new HiddenField('PreviewURL', 'Preview URL', $home)); |
||
| 86 | // Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load |
||
| 87 | $fields->push($navField = new LiteralField( |
||
| 88 | 'SilverStripeNavigator', |
||
| 89 | $this->getSilverStripeNavigator() |
||
| 90 | )); |
||
| 91 | $navField->setAllowHTML(true); |
||
| 92 | // Retrieve validator, if one has been setup (e.g. via data extensions). |
||
| 93 | if ($config->hasMethod('getCMSValidator')) { |
||
| 94 | $validator = $config->getCMSValidator(); |
||
| 95 | } else { |
||
| 96 | $validator = null; |
||
| 97 | } |
||
| 98 | $actions = $config->getCMSActions(); |
||
| 99 | $negotiator = $this->getResponseNegotiator(); |
||
| 100 | $form = Form::create( |
||
| 101 | $this, |
||
| 102 | 'EditForm', |
||
| 103 | $fields, |
||
| 104 | $actions, |
||
| 105 | $validator |
||
| 106 | )->setHTMLID('Form_EditForm'); |
||
| 107 | $form->setValidationResponseCallback(function (ValidationResult $errors) use ($negotiator, $form) { |
||
| 108 | $request = $this->getRequest(); |
||
| 109 | if ($request->isAjax() && $negotiator) { |
||
| 110 | $result = $form->forTemplate(); |
||
| 111 | return $negotiator->respond($request, array( |
||
| 112 | 'CurrentForm' => function () use ($result) { |
||
| 113 | return $result; |
||
| 114 | }, |
||
| 115 | )); |
||
| 116 | } |
||
| 117 | }); |
||
| 118 | $form->addExtraClass('flexbox-area-grow fill-height cms-content cms-edit-form'); |
||
| 119 | $form->setAttribute('data-pjax-fragment', 'CurrentForm'); |
||
| 120 | if ($form->Fields()->hasTabSet()) { |
||
| 121 | $form->Fields()->findOrMakeTab('Root')->setTemplate('SilverStripe\\Forms\\CMSTabSet'); |
||
| 122 | } |
||
| 123 | $form->setHTMLID('Form_EditForm'); |
||
| 124 | $form->loadDataFrom($config); |
||
| 125 | $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); |
||
| 126 | // Use <button> to allow full jQuery UI styling |
||
| 127 | $actions = $actions->dataFields(); |
||
| 128 | if ($actions) { |
||
| 129 | /** @var FormAction $action */ |
||
| 130 | foreach ($actions as $action) { |
||
| 131 | $action->setUseButtonTag(true); |
||
| 132 | } |
||
| 133 | } |
||
| 134 | $this->extend('updateEditForm', $form); |
||
| 135 | return $form; |
||
| 136 | } |
||
| 178 |
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