Code Duplication    Length = 20-22 lines in 2 locations

src/PlaygroundGame/Service/Quiz.php 2 locations

@@ 484-505 (lines=22) @@
481
                if (is_array($a)) {
482
                    foreach ($a as $k => $answer_id) {
483
                        $answer = $this->getQuizAnswerMapper()->findById($answer_id);
484
                        if ($answer) {
485
                            if(isset($quizReplyAnswered[$question->getId()])){
486
                                $this->getQuizReplyAnswerMapper()->remove($quizReplyAnswered[$question->getId()]);
487
                            }
488
489
                            $quizReplyAnswer = new QuizReplyAnswer();
490
                            $quizReplyAnswer->setAnswer($answer->getAnswer());
491
                            $quizReplyAnswer->setAnswerId($answer_id);
492
                            $quizReplyAnswer->setQuestion($question->getQuestion());
493
                            $quizReplyAnswer->setQuestionId($question->getId());
494
                            $quizReplyAnswer->setPoints($answer->getPoints());
495
                            $quizReplyAnswer->setCorrect($answer->getCorrect());
496
497
                            $quizReply->addAnswer($quizReplyAnswer);
498
                            
499
                            $quizPoints += $answer->getPoints();
500
                            $quizCorrectAnswers += $answer->getCorrect();
501
502
                            if (isset($group[$q.'-'.$answer_id.'-data'])) {
503
                                $quizReplyAnswer->setAnswerData($group[$q.'-'.$answer_id.'-data']);
504
                            }
505
                        }
506
                    }
507
                } elseif ($question->getType() == 0 || $question->getType() == 1) {
508
                    ++$totalQuestions;
@@ 510-529 (lines=20) @@
507
                } elseif ($question->getType() == 0 || $question->getType() == 1) {
508
                    ++$totalQuestions;
509
                    $answer = $this->getQuizAnswerMapper()->findById($a);
510
                    if ($answer) {
511
                        if(isset($quizReplyAnswered[$question->getId()])){
512
                            $this->getQuizReplyAnswerMapper()->remove($quizReplyAnswered[$question->getId()]);
513
                        }
514
                        $quizReplyAnswer = new QuizReplyAnswer();
515
                        $quizReplyAnswer->setAnswer($answer->getAnswer());
516
                        $quizReplyAnswer->setAnswerId($a);
517
                        $quizReplyAnswer->setQuestion($question->getQuestion());
518
                        $quizReplyAnswer->setQuestionId($question->getId());
519
                        $quizReplyAnswer->setPoints($answer->getPoints());
520
                        $quizReplyAnswer->setCorrect($answer->getCorrect());
521
522
                        $quizReply->addAnswer($quizReplyAnswer);
523
524
                        $quizPoints += $answer->getPoints();
525
                        $quizCorrectAnswers += $answer->getCorrect();
526
                        if (isset($group[$q.'-'.$a.'-data'])) {
527
                            $quizReplyAnswer->setAnswerData($group[$q.'-'.$a.'-data']);
528
                        }
529
                    }
530
                } elseif ($question->getType() == 2) {
531
                    ++$totalQuestions;
532
                    if(isset($quizReplyAnswered[$question->getId()])){