Code Duplication    Length = 10-11 lines in 6 locations

src/Service/Game.php 4 locations

@@ 232-242 (lines=11) @@
229
            ErrorHandler::stop(true);
230
        }
231
232
        if (isset($data['deleteMainImage']) &&
233
            $data['deleteMainImage'] &&
234
            empty($data['uploadMainImage']['tmp_name'])
235
        ) {
236
            ErrorHandler::start();
237
            $image = $game->getMainImage();
238
            $image = str_replace($media_url, '', $image);
239
            unlink($path . $image);
240
            $game->setMainImage(null);
241
            ErrorHandler::stop(true);
242
        }
243
244
        if (! empty($data['uploadSecondImage']['tmp_name'])) {
245
            ErrorHandler::start();
@@ 255-265 (lines=11) @@
252
            ErrorHandler::stop(true);
253
        }
254
255
        if (isset($data['deleteSecondImage']) &&
256
            $data['deleteSecondImage'] &&
257
            empty($data['uploadSecondImage']['tmp_name'])
258
        ) {
259
            ErrorHandler::start();
260
            $image = $game->getSecondImage();
261
            $image = str_replace($media_url, '', $image);
262
            unlink($path . $image);
263
            $game->setSecondImage(null);
264
            ErrorHandler::stop(true);
265
        }
266
267
        if (! empty($data['uploadStylesheet']['tmp_name'])) {
268
            ErrorHandler::start();
@@ 285-295 (lines=11) @@
282
            ErrorHandler::stop(true);
283
        }
284
285
        if (isset($data['deleteFbShareImage']) &&
286
            $data['deleteFbShareImage'] &&
287
            empty($data['uploadFbShareImage']['tmp_name'])
288
        ) {
289
            ErrorHandler::start();
290
            $image = $game->getFbShareImage();
291
            $image = str_replace($media_url, '', $image);
292
            unlink($path . $image);
293
            $game->setFbShareImage(null);
294
            ErrorHandler::stop(true);
295
        }
296
297
        if (! empty($data['uploadFbPageTabImage']['tmp_name'])) {
298
            ErrorHandler::start();
@@ 314-324 (lines=11) @@
311
            ErrorHandler::stop(true);
312
        }
313
314
        if (isset($data['deleteFbPageTabImage']) &&
315
            $data['deleteFbPageTabImage'] &&
316
            empty($data['uploadFbPageTabImage']['tmp_name'])
317
        ) {
318
            ErrorHandler::start();
319
            $image = $game->getFbPageTabImage();
320
            $image = str_replace($media_url, '', $image);
321
            unlink($path . $image);
322
            $game->setFbPageTabImage(null);
323
            ErrorHandler::stop(true);
324
        }
325
326
        $game = $this->getGameMapper()->update($game);
327

src/Service/InstantWin.php 1 location

@@ 48-58 (lines=11) @@
45
                $game = $this->getGameMapper()->update($game);
46
            }
47
48
            if (isset($data['deleteScratchcardImage']) &&
49
                $data['deleteScratchcardImage'] &&
50
                empty($data['uploadScratchcardImage']['tmp_name'])
51
            ) {
52
                ErrorHandler::start();
53
                $image = $game->getScratchcardImage();
54
                $image = str_replace($media_url, '', $image);
55
                unlink($path .$image);
56
                $game->setScratchcardImage(null);
57
                ErrorHandler::stop(true);
58
            }
59
60
            if ($game->getOccurrenceNumber() && $game->getScheduleOccurrenceAuto()) {
61
                $this->scheduleOccurrences($game, $data);

src/Service/Quiz.php 1 location

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