| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| 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 |
||
| 19 | public function __construct(ContainerInterface $di) |
||
| 20 | { |
||
| 21 | parent::__construct($di); |
||
| 22 | $this->form->create( |
||
| 23 | [ |
||
| 24 | "id" => __CLASS__, |
||
| 25 | "legend" => "Skapa användare", |
||
| 26 | ], |
||
| 27 | [ |
||
| 28 | "acronym" => [ |
||
| 29 | "type" => "text", |
||
| 30 | ], |
||
| 31 | |||
| 32 | "password" => [ |
||
| 33 | "type" => "password", |
||
| 34 | "description" => "Välj ett password", |
||
| 35 | "placeholder" => "Your password", |
||
| 36 | ], |
||
| 37 | |||
| 38 | "hidden" => [ |
||
| 39 | "type" => "hidden", |
||
| 40 | "value" => "secret value", |
||
| 41 | ], |
||
| 42 | // |
||
| 43 | // "select" => [ |
||
| 44 | // "type" => "select", |
||
| 45 | // "label" => "Select your rating:", |
||
| 46 | // "description" => "Here you can place a description.", |
||
| 47 | // "options" => [ |
||
| 48 | // "+1" => 1, |
||
| 49 | // "-1" => -1, |
||
| 50 | // ], |
||
| 51 | // "value" => "potato", |
||
| 52 | // ], |
||
| 53 | |||
| 54 | "password-again" => [ |
||
| 55 | "type" => "password", |
||
| 56 | "validation" => [ |
||
| 57 | "match" => "password" |
||
| 58 | ], |
||
| 59 | ], |
||
| 60 | |||
| 61 | "email" => [ |
||
| 62 | "type" => "email", |
||
| 63 | "description" => "Skriv in din email", |
||
| 64 | "placeholder" => "Your email", |
||
| 65 | ], |
||
| 66 | |||
| 67 | "submit" => [ |
||
| 68 | "type" => "submit", |
||
| 69 | "value" => "Submit", |
||
| 70 | "callback" => [$this, "callbackSubmit"] |
||
| 71 | ], |
||
| 72 | ] |
||
| 73 | ); |
||
| 74 | } |
||
| 75 | |||
| 117 |