Code Duplication    Length = 8-10 lines in 6 locations

src/PlaygroundGame/Service/Game.php 4 locations

@@ 368-375 (lines=8) @@
365
            ErrorHandler::stop(true);
366
        }
367
368
        if (isset($data['deleteMainImage']) && $data['deleteMainImage'] && empty($data['uploadMainImage']['tmp_name'])) {
369
            ErrorHandler::start();
370
            $image = $game->getMainImage();
371
            $image = str_replace($media_url, '', $image);
372
            unlink($path . $image);
373
            $game->setMainImage(null);
374
            ErrorHandler::stop(true);
375
        }
376
377
        if (! empty($data['uploadSecondImage']['tmp_name'])) {
378
            ErrorHandler::start();
@@ 385-392 (lines=8) @@
382
            ErrorHandler::stop(true);
383
        }
384
385
        if (isset($data['deleteSecondImage']) && $data['deleteSecondImage'] && empty($data['uploadSecondImage']['tmp_name'])) {
386
            ErrorHandler::start();
387
            $image = $game->getSecondImage();
388
            $image = str_replace($media_url, '', $image);
389
            unlink($path . $image);
390
            $game->setSecondImage(null);
391
            ErrorHandler::stop(true);
392
        }
393
394
        if (! empty($data['uploadStylesheet']['tmp_name'])) {
395
            ErrorHandler::start();
@@ 409-416 (lines=8) @@
406
            ErrorHandler::stop(true);
407
        }
408
409
        if (isset($data['deleteFbShareImage']) && $data['deleteFbShareImage'] && empty($data['uploadFbShareImage']['tmp_name'])) {
410
            ErrorHandler::start();
411
            $image = $game->getFbShareImage();
412
            $image = str_replace($media_url, '', $image);
413
            unlink($path . $image);
414
            $game->setFbShareImage(null);
415
            ErrorHandler::stop(true);
416
        }
417
418
        if (! empty($data['uploadFbPageTabImage']['tmp_name'])) {
419
            ErrorHandler::start();
@@ 429-436 (lines=8) @@
426
            ErrorHandler::stop(true);
427
        }
428
429
        if (isset($data['deleteFbPageTabImage']) && $data['deleteFbPageTabImage'] && empty($data['uploadFbPageTabImage']['tmp_name'])) {
430
            ErrorHandler::start();
431
            $image = $game->getFbPageTabImage();
432
            $image = str_replace($media_url, '', $image);
433
            unlink($path . $image);
434
            $game->setFbPageTabImage(null);
435
            ErrorHandler::stop(true);
436
        }
437
438
        $game = $this->getGameMapper()->update($game);
439

src/PlaygroundGame/Service/InstantWin.php 1 location

@@ 77-84 (lines=8) @@
74
                $game = $this->getGameMapper()->update($game);
75
            }
76
77
            if (isset($data['deleteScratchcardImage']) && $data['deleteScratchcardImage'] && empty($data['uploadScratchcardImage']['tmp_name'])) {
78
                ErrorHandler::start();
79
                $image = $game->getScratchcardImage();
80
                $image = str_replace($media_url, '', $image);
81
                unlink($path .$image);
82
                $game->setScratchcardImage(null);
83
                ErrorHandler::stop(true);
84
            }
85
86
            if ($game->getOccurrenceNumber() && $game->getScheduleOccurrenceAuto()) {
87
                $this->scheduleOccurrences($game, $data);

src/PlaygroundGame/Service/Quiz.php 1 location

@@ 122-131 (lines=10) @@
119
            ErrorHandler::stop(true);
120
        }
121
122
        if (isset($data['delete_image']) && empty($data['upload_image']['tmp_name'])) {
123
            ErrorHandler::start();
124
            $image = $question->getImage();
125
            $image = str_replace($media_url, '', $image);
126
            if (file_exists($path .$image)) {
127
                unlink($path .$image);
128
            }
129
            $question->setImage(null);
130
            ErrorHandler::stop(true);
131
        }
132
        
133
        $i = 0;
134
        foreach ($question->getAnswers() as $answer) {