| Conditions | 2 |
| Paths | 2 |
| Total Lines | 54 |
| Code Lines | 36 |
| 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 | protected function createContactForm() |
||
| 80 | { |
||
| 81 | $form = UserDefinedForm::create(array( |
||
| 82 | 'Title' => 'Contact', |
||
| 83 | 'URLSegment' => 'contact', |
||
| 84 | 'Content' => '<p>$UserDefinedForm</p>', |
||
| 85 | 'SubmitButtonText' => 'Submit', |
||
| 86 | 'ClearButtonText' => 'Clear', |
||
| 87 | 'OnCompleteMessage' => "<p>Thanks, we've received your submission and will be in touch shortly.</p>", |
||
| 88 | 'EnableLiveValidation' => true |
||
| 89 | )); |
||
| 90 | |||
| 91 | $form->write(); |
||
| 92 | |||
| 93 | // Add form fields |
||
| 94 | $fields = array( |
||
| 95 | EditableFormStep::create([ |
||
| 96 | 'Title' => _t( |
||
| 97 | 'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep.TITLE_FIRST', |
||
| 98 | 'First Page' |
||
| 99 | ) |
||
| 100 | ]), |
||
| 101 | EditableTextField::create([ |
||
| 102 | 'Title' => 'Name', |
||
| 103 | 'Required' => true, |
||
| 104 | 'RightTitle' => 'Please enter your first and last name' |
||
| 105 | ]), |
||
| 106 | EditableEmailField::create([ |
||
| 107 | 'Title' => Email::class, |
||
| 108 | 'Required' => true, |
||
| 109 | 'Placeholder' => '[email protected]' |
||
| 110 | ]), |
||
| 111 | EditableTextField::create([ |
||
| 112 | 'Title' => 'Subject' |
||
| 113 | ]), |
||
| 114 | EditableTextField::create([ |
||
| 115 | 'Title' => 'Message', |
||
| 116 | 'Required' => true, |
||
| 117 | 'Rows' => 5 |
||
| 118 | ]) |
||
| 119 | ); |
||
| 120 | |||
| 121 | foreach ($fields as $field) { |
||
| 122 | $field->write(); |
||
| 123 | $form->Fields()->add($field); |
||
| 124 | $field->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
||
| 125 | } |
||
| 126 | |||
| 127 | $form->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
||
| 128 | $form->flushCache(); |
||
| 129 | |||
| 130 | $this->output(' + Created "contact" UserDefinedForm page'); |
||
| 131 | |||
| 132 | return $this; |
||
| 133 | } |
||
| 153 |
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