Conditions | 1 |
Paths | 1 |
Total Lines | 221 |
Code Lines | 142 |
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 |
||
94 | private function addVenues() |
||
95 | { |
||
96 | $now = new \DateTime(); |
||
97 | |||
98 | // --------- Cherkasy Philharmonic --------------// |
||
99 | $this->connection->insert( |
||
100 | 'venue', |
||
101 | [ |
||
102 | 'title' => 'Черкаська Філармонія', |
||
103 | 'address' => 'вулиця Хрещатик, 196, Черкаси, Черкаська область, Україна, 18000', |
||
104 | 'hallTemplate' => '<div></div>', |
||
105 | 'createdAt' => $now->format('Y-m-d H:i:s'), |
||
106 | ] |
||
107 | ); |
||
108 | $id = $this->connection->lastInsertId(); |
||
109 | $this->venues['venue-philharmonic'] = $id; |
||
110 | $this->connection->insert( |
||
111 | 'venue_translation', |
||
112 | [ |
||
113 | 'object_id' => $id, |
||
114 | 'locale' => 'en', |
||
115 | 'field' => 'title', |
||
116 | 'content' => 'Cherkasy Philharmonic', |
||
117 | ] |
||
118 | ); |
||
119 | $this->connection->insert( |
||
120 | 'venue_translation', |
||
121 | [ |
||
122 | 'object_id' => $id, |
||
123 | 'locale' => 'en', |
||
124 | 'field' => 'address', |
||
125 | 'content' => 'Khreshchatyk Street, 196, Cherkasy region, Ukraine, 18000', |
||
126 | ] |
||
127 | ); |
||
128 | |||
129 | // --------- Kulik's House of Culture --------------// |
||
130 | $this->connection->insert( |
||
131 | 'venue', |
||
132 | [ |
||
133 | 'title' => 'Будинок культури ім. Кулика', |
||
134 | 'address' => 'вулиця Благовісна, 170, Черкаси, Черкаська область, Україна, 18000', |
||
135 | 'hallTemplate' => '<div></div>', |
||
136 | 'createdAt' => $now->format('Y-m-d H:i:s'), |
||
137 | ] |
||
138 | ); |
||
139 | $id = $this->connection->lastInsertId(); |
||
140 | $this->venues['venue-kilic-house'] = $id; |
||
141 | $this->connection->insert( |
||
142 | 'venue_translation', |
||
143 | [ |
||
144 | 'object_id' => $id, |
||
145 | 'locale' => 'en', |
||
146 | 'field' => 'title', |
||
147 | 'content' => 'Kulik\'s House of Culture', |
||
148 | ] |
||
149 | ); |
||
150 | $this->connection->insert( |
||
151 | 'venue_translation', |
||
152 | [ |
||
153 | 'object_id' => $id, |
||
154 | 'locale' => 'en', |
||
155 | 'field' => 'address', |
||
156 | 'content' => 'Blahovisna Street 170, Cherkasy region, Ukraine, 18000', |
||
157 | ] |
||
158 | ); |
||
159 | |||
160 | // --------- Cherkasy Theatre --------------// |
||
161 | $this->connection->insert( |
||
162 | 'venue', |
||
163 | [ |
||
164 | 'title' => 'Черкаський Театр', |
||
165 | 'address' => 'бульвар Шевченка, 234, Черкаси, Черкаська, Україна, 18000', |
||
166 | 'hallTemplate' => '<div></div>', |
||
167 | 'createdAt' => $now->format('Y-m-d H:i:s'), |
||
168 | ] |
||
169 | ); |
||
170 | $id = $this->connection->lastInsertId(); |
||
171 | $this->venues['venue-theatre'] = $id; |
||
172 | $this->connection->insert( |
||
173 | 'venue_translation', |
||
174 | [ |
||
175 | 'object_id' => $id, |
||
176 | 'locale' => 'en', |
||
177 | 'field' => 'title', |
||
178 | 'content' => 'Cherkasy Theatre', |
||
179 | ] |
||
180 | ); |
||
181 | $this->connection->insert( |
||
182 | 'venue_translation', |
||
183 | [ |
||
184 | 'object_id' => $id, |
||
185 | 'locale' => 'en', |
||
186 | 'field' => 'address', |
||
187 | 'content' => 'Boulevard Shevchenko, 234 Cherkasy, Ukraine, 18000', |
||
188 | ] |
||
189 | ); |
||
190 | |||
191 | // --------- Cinema "Salute" --------------// |
||
192 | $this->connection->insert( |
||
193 | 'venue', |
||
194 | [ |
||
195 | 'title' => 'Кінотеатр "Салют"', |
||
196 | 'address' => 'вулиця Хрещатик, 170, Черкаси, Черкаська область, Україна, 18000', |
||
197 | 'hallTemplate' => '<div></div>', |
||
198 | 'createdAt' => $now->format('Y-m-d H:i:s'), |
||
199 | ] |
||
200 | ); |
||
201 | $id = $this->connection->lastInsertId(); |
||
202 | $this->venues['venue-salut'] = $id; |
||
203 | $this->connection->insert( |
||
204 | 'venue_translation', |
||
205 | [ |
||
206 | 'object_id' => $id, |
||
207 | 'locale' => 'en', |
||
208 | 'field' => 'title', |
||
209 | 'content' => 'Cinema "Salute"', |
||
210 | ] |
||
211 | ); |
||
212 | $this->connection->insert( |
||
213 | 'venue_translation', |
||
214 | [ |
||
215 | 'object_id' => $id, |
||
216 | 'locale' => 'en', |
||
217 | 'field' => 'address', |
||
218 | 'content' => 'Khreshchatyk Street, 170, Cherkasy region, Ukraine, 18000', |
||
219 | ] |
||
220 | ); |
||
221 | |||
222 | // --------- Cherkasky City Palace of Youth --------------// |
||
223 | $this->connection->insert( |
||
224 | 'venue', |
||
225 | [ |
||
226 | 'title' => 'Черкаський міський Палац молоді', |
||
227 | 'address' => 'вулиця Сумгаїтська, 12, Черкаси, Черкаська область, Україна, 18000', |
||
228 | 'hallTemplate' => '<div></div>', |
||
229 | 'createdAt' => $now->format('Y-m-d H:i:s'), |
||
230 | ] |
||
231 | ); |
||
232 | $id = $this->connection->lastInsertId(); |
||
233 | $this->venues['venue-palac_molodi'] = $id; |
||
234 | $this->connection->insert( |
||
235 | 'venue_translation', |
||
236 | [ |
||
237 | 'object_id' => $id, |
||
238 | 'locale' => 'en', |
||
239 | 'field' => 'title', |
||
240 | 'content' => 'Cherkasky City Palace of Youth', |
||
241 | ] |
||
242 | ); |
||
243 | $this->connection->insert( |
||
244 | 'venue_translation', |
||
245 | [ |
||
246 | 'object_id' => $id, |
||
247 | 'locale' => 'en', |
||
248 | 'field' => 'address', |
||
249 | 'content' => 'Street Sumgait, 12, Cherkasy region, Ukraine, 18000', |
||
250 | ] |
||
251 | ); |
||
252 | |||
253 | // --------- Center for Children and Youth --------------// |
||
254 | $this->connection->insert( |
||
255 | 'venue', |
||
256 | [ |
||
257 | 'title' => 'Центр дитячої та юнацької творчості', |
||
258 | 'address' => 'вулиця Смілянська, 33, Черкаси, Черкаська область, Україна, 18000', |
||
259 | 'hallTemplate' => '<div></div>', |
||
260 | 'createdAt' => $now->format('Y-m-d H:i:s'), |
||
261 | ] |
||
262 | ); |
||
263 | $id = $this->connection->lastInsertId(); |
||
264 | $this->venues['venue-center_of_kids_arts'] = $id; |
||
265 | $this->connection->insert( |
||
266 | 'venue_translation', |
||
267 | [ |
||
268 | 'object_id' => $id, |
||
269 | 'locale' => 'en', |
||
270 | 'field' => 'title', |
||
271 | 'content' => 'Center for Children and Youth', |
||
272 | ] |
||
273 | ); |
||
274 | $this->connection->insert( |
||
275 | 'venue_translation', |
||
276 | [ |
||
277 | 'object_id' => $id, |
||
278 | 'locale' => 'en', |
||
279 | 'field' => 'address', |
||
280 | 'content' => 'Smilians\'ka Street, 33, Cherkasy region, Ukraine, 18000', |
||
281 | ] |
||
282 | ); |
||
283 | |||
284 | // --------- Cherkassy Regional Art Museum --------------// |
||
285 | $this->connection->insert( |
||
286 | 'venue', |
||
287 | [ |
||
288 | 'title' => 'Черкаський обласний художній музей', |
||
289 | 'address' => 'вулиця Хрещатик, 259, Черкаси, Черкаська область, Україна, 18000', |
||
290 | 'hallTemplate' => '<div></div>', |
||
291 | 'createdAt' => $now->format('Y-m-d H:i:s'), |
||
292 | ] |
||
293 | ); |
||
294 | $id = $this->connection->lastInsertId(); |
||
295 | $this->venues['venue-cherkasy-art-museum'] = $id; |
||
296 | $this->connection->insert( |
||
297 | 'venue_translation', |
||
298 | [ |
||
299 | 'object_id' => $id, |
||
300 | 'locale' => 'en', |
||
301 | 'field' => 'title', |
||
302 | 'content' => 'Cherkassy Regional Art Museum', |
||
303 | ] |
||
304 | ); |
||
305 | $this->connection->insert( |
||
306 | 'venue_translation', |
||
307 | [ |
||
308 | 'object_id' => $id, |
||
309 | 'locale' => 'en', |
||
310 | 'field' => 'address', |
||
311 | 'content' => 'Khreshchatyk Street, 259, Cherkasy region, Ukraine, 18000', |
||
312 | ] |
||
313 | ); |
||
314 | } |
||
315 | |||
334 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.