| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 35 |
| 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 |
||
| 15 | public function createValidator(): IValidator |
||
| 16 | { |
||
| 17 | $validator = parent::createValidator(); |
||
| 18 | |||
| 19 | $validator |
||
| 20 | ->field('id') |
||
| 21 | ->forbidden(); |
||
| 22 | |||
| 23 | $validator |
||
| 24 | ->field('identifier'); |
||
| 25 | |||
| 26 | $validator |
||
| 27 | ->field('classes'); |
||
| 28 | |||
| 29 | $validator |
||
| 30 | ->field('title') |
||
| 31 | ->required(); |
||
| 32 | |||
| 33 | $validator |
||
| 34 | ->field('lede'); |
||
| 35 | |||
| 36 | $validator |
||
| 37 | ->field('body'); |
||
| 38 | |||
| 39 | $validator |
||
| 40 | ->field('is_draft') |
||
| 41 | ->numeric(); |
||
| 42 | |||
| 43 | $validator |
||
| 44 | ->field('category_id') |
||
| 45 | ->uuid(); |
||
| 46 | |||
| 47 | $validator |
||
| 48 | ->field('layout_id') |
||
| 49 | ->uuid(); |
||
| 50 | |||
| 51 | $validator |
||
| 52 | ->field('layout'); |
||
| 53 | |||
| 54 | $validator |
||
| 55 | ->field('header'); |
||
| 56 | |||
| 57 | $validator |
||
| 58 | ->field('footer'); |
||
| 59 | |||
| 60 | $validator |
||
| 61 | ->field('css_files'); |
||
| 62 | |||
| 63 | $validator |
||
| 64 | ->field('js_files'); |
||
| 65 | |||
| 66 | return $validator; |
||
| 67 | } |
||
| 69 |