Code Duplication    Length = 20-22 lines in 2 locations

src/Service/Quiz.php 2 locations

@@ 511-532 (lines=22) @@
508
                    if (is_array($a)) {
509
                        foreach ($a as $k => $answer_id) {
510
                            $answer = $this->getQuizAnswerMapper()->findById($answer_id);
511
                            if ($answer) {
512
                                if (isset($quizReplyAnswered[$question->getId()])) {
513
                                    $this->getQuizReplyAnswerMapper()->remove($quizReplyAnswered[$question->getId()]);
514
                                }
515
516
                                $quizReplyAnswer = new QuizReplyAnswer();
517
                                $quizReplyAnswer->setAnswer($answer->getAnswer());
518
                                $quizReplyAnswer->setAnswerId($answer_id);
519
                                $quizReplyAnswer->setQuestion($question->getQuestion());
520
                                $quizReplyAnswer->setQuestionId($question->getId());
521
                                $quizReplyAnswer->setPoints($answer->getPoints());
522
                                $quizReplyAnswer->setCorrect($answer->getCorrect());
523
524
                                $quizReply->addAnswer($quizReplyAnswer);
525
526
                                $quizPoints += $answer->getPoints();
527
                                $quizCorrectAnswers += $answer->getCorrect();
528
529
                                if (isset($group[$q.'-'.$answer_id.'-data'])) {
530
                                    $quizReplyAnswer->setAnswerData($group[$q.'-'.$answer_id.'-data']);
531
                                }
532
                            }
533
                        }
534
                    } elseif ($question->getType() == 0 || $question->getType() == 1) {
535
                        ++$totalQuestions;
@@ 537-556 (lines=20) @@
534
                    } elseif ($question->getType() == 0 || $question->getType() == 1) {
535
                        ++$totalQuestions;
536
                        $answer = $this->getQuizAnswerMapper()->findById($a);
537
                        if ($answer) {
538
                            if (isset($quizReplyAnswered[$question->getId()])) {
539
                                $this->getQuizReplyAnswerMapper()->remove($quizReplyAnswered[$question->getId()]);
540
                            }
541
                            $quizReplyAnswer = new QuizReplyAnswer();
542
                            $quizReplyAnswer->setAnswer($answer->getAnswer());
543
                            $quizReplyAnswer->setAnswerId($a);
544
                            $quizReplyAnswer->setQuestion($question->getQuestion());
545
                            $quizReplyAnswer->setQuestionId($question->getId());
546
                            $quizReplyAnswer->setPoints($answer->getPoints());
547
                            $quizReplyAnswer->setCorrect($answer->getCorrect());
548
549
                            $quizReply->addAnswer($quizReplyAnswer);
550
551
                            $quizPoints += $answer->getPoints();
552
                            $quizCorrectAnswers += $answer->getCorrect();
553
                            if (isset($group[$q.'-'.$a.'-data'])) {
554
                                $quizReplyAnswer->setAnswerData($group[$q.'-'.$a.'-data']);
555
                            }
556
                        }
557
                    } elseif ($question->getType() == 2) {
558
                        ++$totalQuestions;
559
                        if (isset($quizReplyAnswered[$question->getId()])) {