Code Duplication    Length = 18-18 lines in 2 locations

src/PlaygroundGame/Controller/Admin/QuizController.php 2 locations

@@ 72-89 (lines=18) @@
69
        $question = new QuizQuestion();
70
        $form->bind($question);
71
72
        if ($this->getRequest()->isPost()) {
73
            $data = array_replace_recursive(
74
                $this->getRequest()->getPost()->toArray(),
75
                $this->getRequest()->getFiles()->toArray()
76
            );
77
78
            $question = $service->createQuestion($data);
79
            if ($question) {
80
                // Redirect to list of games
81
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The question was created');
82
83
                return $this->redirect()->toRoute('admin/playgroundgame/quiz-question-list', array('quizId'=>$quizId));
84
            } else { // Creation failed
85
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage(
86
                    'The question was not updated - create at least one good answer'
87
                );
88
            }
89
        }
90
91
        return $viewModel->setVariables(array('form' => $form, 'quiz_id' => $quizId, 'question_id' => 0));
92
    }
@@ 118-135 (lines=18) @@
115
116
        $form->bind($question);
117
118
        if ($this->getRequest()->isPost()) {
119
            $data = array_replace_recursive(
120
                $this->getRequest()->getPost()->toArray(),
121
                $this->getRequest()->getFiles()->toArray()
122
            );
123
124
            $question = $service->updateQuestion($data, $question);
125
            if ($question) {
126
                // Redirect to list of games
127
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The question was updated');
128
129
                return $this->redirect()->toRoute('admin/playgroundgame/quiz-question-list', array('quizId'=>$quizId));
130
            } else {
131
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage(
132
                    'The question was not updated - create at least one good answer'
133
                );
134
            }
135
        }
136
137
        return $viewModel->setVariables(array('form' => $form, 'quiz_id' => $quizId, 'question_id' => $questionId));
138
    }