Code Duplication    Length = 10-11 lines in 6 locations

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) {

src/Service/Game.php 4 locations

@@ 235-245 (lines=11) @@
232
            ErrorHandler::stop(true);
233
        }
234
235
        if (isset($data['deleteMainImage']) &&
236
            $data['deleteMainImage'] &&
237
            empty($data['uploadMainImage']['tmp_name'])
238
        ) {
239
            ErrorHandler::start();
240
            $image = $game->getMainImage();
241
            $image = str_replace($media_url, '', $image);
242
            unlink($path . $image);
243
            $game->setMainImage(null);
244
            ErrorHandler::stop(true);
245
        }
246
247
        if (! empty($data['uploadSecondImage']['tmp_name'])) {
248
            ErrorHandler::start();
@@ 258-268 (lines=11) @@
255
            ErrorHandler::stop(true);
256
        }
257
258
        if (isset($data['deleteSecondImage']) &&
259
            $data['deleteSecondImage'] &&
260
            empty($data['uploadSecondImage']['tmp_name'])
261
        ) {
262
            ErrorHandler::start();
263
            $image = $game->getSecondImage();
264
            $image = str_replace($media_url, '', $image);
265
            unlink($path . $image);
266
            $game->setSecondImage(null);
267
            ErrorHandler::stop(true);
268
        }
269
270
        if (! empty($data['uploadStylesheet']['tmp_name'])) {
271
            ErrorHandler::start();
@@ 288-298 (lines=11) @@
285
            ErrorHandler::stop(true);
286
        }
287
288
        if (isset($data['deleteFbShareImage']) &&
289
            $data['deleteFbShareImage'] &&
290
            empty($data['uploadFbShareImage']['tmp_name'])
291
        ) {
292
            ErrorHandler::start();
293
            $image = $game->getFbShareImage();
294
            $image = str_replace($media_url, '', $image);
295
            unlink($path . $image);
296
            $game->setFbShareImage(null);
297
            ErrorHandler::stop(true);
298
        }
299
300
        if (! empty($data['uploadFbPageTabImage']['tmp_name'])) {
301
            ErrorHandler::start();
@@ 317-327 (lines=11) @@
314
            ErrorHandler::stop(true);
315
        }
316
317
        if (isset($data['deleteFbPageTabImage']) &&
318
            $data['deleteFbPageTabImage'] &&
319
            empty($data['uploadFbPageTabImage']['tmp_name'])
320
        ) {
321
            ErrorHandler::start();
322
            $image = $game->getFbPageTabImage();
323
            $image = str_replace($media_url, '', $image);
324
            unlink($path . $image);
325
            $game->setFbPageTabImage(null);
326
            ErrorHandler::stop(true);
327
        }
328
329
        // Let's remove the fbPostId if there is no post to send anymore
330
        if ($data['broadcastPostFacebook'] == 0) {