Code Duplication    Length = 16-18 lines in 3 locations

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

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

src/PlaygroundGame/Controller/Admin/InstantWinController.php 1 location

@@ 308-323 (lines=16) @@
305
306
        $form->bind($occurrence);
307
308
        if ($this->getRequest()->isPost()) {
309
            $data = array_merge(
310
                $this->getRequest()->getPost()->toArray(),
311
                $this->getRequest()->getFiles()->toArray()
312
            );
313
            $occurrence = $service->updateOccurrence($data, $occurrence->getId());
314
315
            if ($occurrence) {
316
                // Redirect to list of games
317
                $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The occurrence was edited');
318
                return $this->redirect()->toRoute(
319
                    'admin/playgroundgame/instantwin-occurrence-list',
320
                    array('gameId'=>$this->game->getId())
321
                );
322
            }
323
        }
324
        return $viewModel->setVariables(
325
            array(
326
                'form' => $form,