Code Duplication    Length = 13-13 lines in 2 locations

src/PlaygroundGame/Service/Game.php 2 locations

@@ 234-246 (lines=13) @@
231
        if (isset($data['prizes'])) {
232
            foreach ($data['prizes'] as $prize_data) {
233
                if (! empty($prize_data['picture']['tmp_name'])) {
234
                    if ($prize_data['id']) {
235
                        $prize = $prize_mapper->findById($prize_data['id']);
236
                    } else {
237
                        $some_prizes = $prize_mapper->findBy(array(
238
                            'game' => $game,
239
                            'title' => $prize_data['title']
240
                        ));
241
                        if (count($some_prizes) == 1) {
242
                            $prize = $some_prizes[0];
243
                        } else {
244
                            return false;
245
                        }
246
                    }
247
                    ErrorHandler::start();
248
                    $filename = "game-" . $game->getId() . "-prize-";
249
                    $filename .= $prize->getId() . "-" . $prize_data['picture']['name'];
@@ 494-506 (lines=13) @@
491
        if (isset($data['prizes'])) {
492
            foreach ($data['prizes'] as $prize_data) {
493
                if (! empty($prize_data['picture_file']['tmp_name']) && ! $prize_data['picture_file']['error']) {
494
                    if ($prize_data['id']) {
495
                        $prize = $prize_mapper->findById($prize_data['id']);
496
                    } else {
497
                        $some_prizes = $prize_mapper->findBy(array(
498
                            'game' => $game,
499
                            'title' => $prize_data['title']
500
                        ));
501
                        if (count($some_prizes) == 1) {
502
                            $prize = $some_prizes[0];
503
                        } else {
504
                            return false;
505
                        }
506
                    }
507
                    // Remove if existing image
508
                    if ($prize->getPicture() && file_exists($prize->getPicture())) {
509
                        unlink($prize->getPicture());