Code Duplication    Length = 20-22 lines in 2 locations

src/Service/Quiz.php 2 locations

@@ 547-568 (lines=22) @@
544
                    if (is_array($a)) {
545
                        foreach ($a as $k => $answer_id) {
546
                            $answer = $this->getQuizAnswerMapper()->findById($answer_id);
547
                            if ($answer) {
548
                                if (isset($quizReplyAnswered[$question->getId()])) {
549
                                    $this->getQuizReplyAnswerMapper()->remove($quizReplyAnswered[$question->getId()]);
550
                                }
551
552
                                $quizReplyAnswer = new QuizReplyAnswer();
553
                                $quizReplyAnswer->setAnswer($answer->getAnswer());
554
                                $quizReplyAnswer->setAnswerId($answer_id);
555
                                $quizReplyAnswer->setQuestion($question->getQuestion());
556
                                $quizReplyAnswer->setQuestionId($question->getId());
557
                                $quizReplyAnswer->setPoints($answer->getPoints());
558
                                $quizReplyAnswer->setCorrect($answer->getCorrect());
559
560
                                $quizReply->addAnswer($quizReplyAnswer);
561
562
                                $quizPoints += $answer->getPoints();
563
                                $quizCorrectAnswers += $answer->getCorrect();
564
565
                                if (isset($group[$q.'-'.$answer_id.'-data'])) {
566
                                    $quizReplyAnswer->setAnswerData($group[$q.'-'.$answer_id.'-data']);
567
                                }
568
                            }
569
                        }
570
                    } elseif ($question->getType() == 0 || $question->getType() == 1) {
571
                        ++$totalQuestions;
@@ 573-592 (lines=20) @@
570
                    } elseif ($question->getType() == 0 || $question->getType() == 1) {
571
                        ++$totalQuestions;
572
                        $answer = $this->getQuizAnswerMapper()->findById($a);
573
                        if ($answer) {
574
                            if (isset($quizReplyAnswered[$question->getId()])) {
575
                                $this->getQuizReplyAnswerMapper()->remove($quizReplyAnswered[$question->getId()]);
576
                            }
577
                            $quizReplyAnswer = new QuizReplyAnswer();
578
                            $quizReplyAnswer->setAnswer($answer->getAnswer());
579
                            $quizReplyAnswer->setAnswerId($a);
580
                            $quizReplyAnswer->setQuestion($question->getQuestion());
581
                            $quizReplyAnswer->setQuestionId($question->getId());
582
                            $quizReplyAnswer->setPoints($answer->getPoints());
583
                            $quizReplyAnswer->setCorrect($answer->getCorrect());
584
585
                            $quizReply->addAnswer($quizReplyAnswer);
586
587
                            $quizPoints += $answer->getPoints();
588
                            $quizCorrectAnswers += $answer->getCorrect();
589
                            if (isset($group[$q.'-'.$a.'-data'])) {
590
                                $quizReplyAnswer->setAnswerData($group[$q.'-'.$a.'-data']);
591
                            }
592
                        }
593
                    } elseif ($question->getType() == 2) {
594
                        ++$totalQuestions;
595
                        if (isset($quizReplyAnswered[$question->getId()])) {