| Conditions | 14 | 
| Paths | 14 | 
| Total Lines | 86 | 
| Code Lines | 61 | 
| 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 declare(strict_types=1);  | 
            ||
| 30 | public function editable($value, Field $field, HTMLNode $previous): HTMLNode  | 
            ||
| 31 |     { | 
            ||
| 32 | $validators = $field->getValidators();  | 
            ||
| 33 | |||
| 34 | |||
| 35 |         foreach ($validators as $validator => $data) { | 
            ||
| 36 |             switch ($validator) { | 
            ||
| 37 | case Datatype::REQUIRED:  | 
            ||
| 38 | case Filled::class:  | 
            ||
| 39 | $this->setValidations(  | 
            ||
| 40 | $field,  | 
            ||
| 41 | 'required',  | 
            ||
| 42 | 'required'  | 
            ||
| 43 | );  | 
            ||
| 44 | break;  | 
            ||
| 45 | case Equals::class:  | 
            ||
| 46 | // TODO  | 
            ||
| 47 | break;  | 
            ||
| 48 | |||
| 49 | case In::class:  | 
            ||
| 50 | // TODO  | 
            ||
| 51 | break;  | 
            ||
| 52 | |||
| 53 | case Max::class:  | 
            ||
| 54 | $this->setValidations(  | 
            ||
| 55 | $field,  | 
            ||
| 56 | 'maxValue',  | 
            ||
| 57 |                     'maxValue(' . $field->getValidatorOption($validator, 'value', '') . ')' | 
            ||
| 58 | );  | 
            ||
| 59 | break;  | 
            ||
| 60 | case Min::class:  | 
            ||
| 61 | $this->setValidations(  | 
            ||
| 62 | $field,  | 
            ||
| 63 | 'minValue',  | 
            ||
| 64 |                     'minValue(' . $field->getValidatorOption($validator, 'value', '') . ')' | 
            ||
| 65 | );  | 
            ||
| 66 | break;  | 
            ||
| 67 | |||
| 68 | case MaxLength::class:  | 
            ||
| 69 | $this->setValidations(  | 
            ||
| 70 | $field,  | 
            ||
| 71 | 'maxLength',  | 
            ||
| 72 |                     'maxLength(' . $field->getValidatorOption($validator, 'value', '') . ')' | 
            ||
| 73 | );  | 
            ||
| 74 | break;  | 
            ||
| 75 | case MinLength::class:  | 
            ||
| 76 | $this->setValidations(  | 
            ||
| 77 | $field,  | 
            ||
| 78 | 'minLength',  | 
            ||
| 79 |                     'minLength(' . $field->getValidatorOption($validator, 'value', '') . ')' | 
            ||
| 80 | );  | 
            ||
| 81 | break;  | 
            ||
| 82 | |||
| 83 | case NotIn::class:  | 
            ||
| 84 | // TODO  | 
            ||
| 85 | break;  | 
            ||
| 86 | |||
| 87 | case Password::class:  | 
            ||
| 88 | // TODO  | 
            ||
| 89 | break;  | 
            ||
| 90 | |||
| 91 | case Regex::class:  | 
            ||
| 92 | $name = 'regex' . mt_rand();  | 
            ||
| 93 | $this->setValidations(  | 
            ||
| 94 | $field,  | 
            ||
| 95 | $name,  | 
            ||
| 96 | 'helpers.regex(\'' . $name . '\', /' . $field->getValidatorOption($validator, 'value', '') . '/)',  | 
            ||
| 97 | 'helpers'  | 
            ||
| 98 | );  | 
            ||
| 99 | break;  | 
            ||
| 100 | |||
| 101 | case SameAs::class:  | 
            ||
| 102 | $target = $field->getValidatorOption($validator, 'value', '');  | 
            ||
| 103 | $locator = $target;// TODO  | 
            ||
| 104 | $this->setValidations(  | 
            ||
| 105 | $field,  | 
            ||
| 106 | 'sameAs',  | 
            ||
| 107 |                     'sameAs(' . $locator . ')' | 
            ||
| 108 | );  | 
            ||
| 109 | break;  | 
            ||
| 110 | default:  | 
            ||
| 111 | break;  | 
            ||
| 112 | }  | 
            ||
| 113 | }  | 
            ||
| 114 | |||
| 115 | return $previous;  | 
            ||
| 116 | }  | 
            ||
| 144 |