Conditions | 3 |
Paths | 2 |
Total Lines | 92 |
Code Lines | 61 |
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 |
||
35 | protected function build($builder) |
||
36 | { |
||
37 | $builder |
||
38 | ->add('name', TextType::class, array( |
||
39 | 'constraints' => [ |
||
40 | new NotBlank(), |
||
41 | new Length([ |
||
42 | 'min' => 2, |
||
43 | 'max' => 40, |
||
44 | ]), |
||
45 | ], |
||
46 | 'required' => true, |
||
47 | )) |
||
48 | ->add('alias', TextType::class, array( |
||
49 | 'constraints' => [ |
||
50 | new Length([ |
||
51 | 'max' => 40, |
||
52 | ]), |
||
53 | new UniqueAlias('Map', $this->editing), |
||
54 | new Type([ |
||
55 | 'type' => 'alpha' |
||
56 | ]), |
||
57 | ], |
||
58 | 'label' => 'Mapchange Configuration Name', |
||
59 | 'required' => true |
||
60 | )) |
||
61 | ->add('description', TextareaType::class, array( |
||
62 | 'constraints' => [ |
||
63 | new NotBlank(), |
||
64 | new Length([ |
||
65 | 'min' => 10 |
||
66 | ]), |
||
67 | ], |
||
68 | 'required' => true, |
||
69 | )) |
||
70 | ->add('world_size', IntegerType::class, [ |
||
71 | 'constraints' => [ |
||
72 | new GreaterThanOrEqual([ |
||
73 | 'value' => 200 |
||
74 | ]), |
||
75 | ], |
||
76 | 'label' => 'BZDB _worldSize', |
||
77 | 'required' => true, |
||
78 | ]) |
||
79 | ->add('randomly_generated', CheckboxType::class, [ |
||
80 | 'label' => 'Map is randomly generated', |
||
81 | 'required' => false, |
||
82 | ]) |
||
83 | ->add('avatar', FileType::class, array( |
||
84 | 'constraints' => new Image(array( |
||
85 | 'minWidth' => 60, |
||
86 | 'minHeight' => 60, |
||
87 | 'maxSize' => '8M' |
||
88 | )), |
||
89 | 'required' => ($this->editing === null || $this->editing->hasAvatar()) |
||
90 | )) |
||
91 | ->add('shot_count', IntegerType::class, [ |
||
92 | 'constraints' => [ |
||
93 | new GreaterThan([ |
||
94 | 'value' => 0 |
||
95 | ]), |
||
96 | ], |
||
97 | 'label' => 'Max shot count', |
||
98 | 'required' => true, |
||
99 | ]) |
||
100 | ->add('jumping', CheckboxType::class, [ |
||
101 | 'label' => 'Map allows jumping', |
||
102 | 'required' => false, |
||
103 | ]) |
||
104 | ->add('ricochet', CheckboxType::class, [ |
||
105 | 'label' => 'Map allows ricochet', |
||
106 | 'required' => false, |
||
107 | ]) |
||
108 | ->add('game_mode', ChoiceType::class, [ |
||
109 | 'choices' => [ |
||
110 | \Map::GAME_MODE_CTF => 'CTF', |
||
111 | \Map::GAME_MODE_AHOD => 'AHOD', |
||
112 | ], |
||
113 | 'multiple' => false, |
||
114 | 'label' => 'Game Mode', |
||
115 | ]) |
||
116 | ; |
||
117 | |||
118 | if ($this->editing) { |
||
119 | // We are editing the map, not creating it |
||
120 | $builder->add('delete_avatar', SubmitType::class); |
||
121 | } |
||
122 | |||
123 | return $builder->add('submit', SubmitType::class, [ |
||
124 | 'label' => 'Save' |
||
125 | ]); |
||
126 | } |
||
127 | |||
193 |