Code Duplication    Length = 32-37 lines in 2 locations

src/Service/InstantWin.php 2 locations

@@ 231-262 (lines=32) @@
228
                }
229
230
                break;
231
            case 'hour':
232
                $nbInterval = (int) ($dateInterval/60);
233
234
                // If a hour don't last 60min, I consider it as a hour anyway.
235
                if ($dateInterval%60 > 0) {
236
                    ++$nbInterval;
237
                }
238
                if ($nbInterval > 0) {
239
                    $nbOccurencesToCreate = $game->getOccurrenceNumber() - floor($nbExistingOccurrences/$nbInterval);
240
                }
241
242
                $beginningDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y H:i:s'));
243
                $endDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y H'). ':59:59');
244
                
245
                if ($nbOccurencesToCreate > 0) {
246
                    for ($d=1; $d<=$nbInterval; $d++) {
247
                        $this->createRandomOccurrences(
248
                            $game,
249
                            $beginningDrawDate,
250
                            $endDrawDate,
251
                            $nbOccurencesToCreate
252
                        );
253
                        $beginningDrawDate = \DateTime::createFromFormat(
254
                            'm/d/Y H:i:s',
255
                            $beginningDrawDate->format('m/d/Y H'). ':00:00'
256
                        );
257
                        $beginningDrawDate->add(new \DateInterval('PT1H'));
258
                        $endDrawDate->add(new \DateInterval('PT1H'));
259
                    }
260
                }
261
262
                break;
263
            case 'day':
264
                $nbInterval = (int) ($dateInterval/(60*24));
265
@@ 263-299 (lines=37) @@
260
                }
261
262
                break;
263
            case 'day':
264
                $nbInterval = (int) ($dateInterval/(60*24));
265
266
                // Prise en compte des changements d'horaires
267
                // If a day don't last 24h, I consider it as a day anyway
268
269
                if ($dateInterval%(60*24) > 0) {
270
                    ++$nbInterval;
271
                }
272
273
                if ($nbInterval > 0) {
274
                    $nbOccurencesToCreate = $game->getOccurrenceNumber() - floor($nbExistingOccurrences/$nbInterval);
275
                }
276
277
                $beginningDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y H:i:s'));
278
                $endDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y'). ' 23:59:59');
279
                
280
                if ($nbOccurencesToCreate > 0) {
281
                    for ($d=1; $d<=$nbInterval; $d++) {
282
                        $this->createRandomOccurrences(
283
                            $game,
284
                            $beginningDrawDate,
285
                            $endDrawDate,
286
                            $nbOccurencesToCreate
287
                        );
288
                        // As the first beginning date was not @ midnight,
289
                        // I recreate the beginning date
290
                        $beginningDrawDate = \DateTime::createFromFormat(
291
                            'm/d/Y H:i:s',
292
                            $beginningDrawDate->format('m/d/Y'). ' 00:00:00'
293
                        );
294
                        $beginningDrawDate->add(new \DateInterval('P1D'));
295
                        $endDrawDate->add(new \DateInterval('P1D'));
296
                    }
297
                }
298
299
                break;
300
            case 'week':
301
                $nbOccurencesToCreate = $game->getOccurrenceNumber() - $nbExistingOccurrences;
302
                $nbWeeksInterval = (int) ($dateInterval/(60*24*7));