Code Duplication    Length = 5-8 lines in 3 locations

src/Badger/Bundle/GameBundle/Controller/BadgeCompletionController.php 3 locations

@@ 171-178 (lines=8) @@
168
            $token = new UsernamePasswordToken($user, 'none', 'none', $user->getRoles());
169
            $isUnlockable = $this->get('security.access.public_decision_manager')->decide($token, ['view'], $badge);
170
171
            if (!$isUnlockable) {
172
                $this->addFlash(
173
                    'error',
174
                    sprintf('%s does not have access to badge "%s"', $user->getUsername(), $badge->getTitle())
175
                );
176
177
                return $this->redirectToRoute('admin_unlocked_badge_give');
178
            }
179
180
            $badgeCompletion = $this->get('badger.game.repository.badge_completion')
181
                ->findOneBy([
@@ 190-197 (lines=8) @@
187
                $badgeCompletion = $this->get('badger.game.badge_completion.factory')->create($user, $badge);
188
            }
189
190
            if (!$badgeCompletion->isPending()) {
191
                $this->addFlash(
192
                    'error',
193
                    sprintf('%s already has the badge "%s"', $user->getUsername(), $badge->getTitle())
194
                );
195
196
                return $this->redirectToRoute('admin_unlocked_badge_give');
197
            }
198
199
            $badgeCompletion->setPending(false);
200
            $badgeCompletion->setCompletionDate(new \DateTime());
@@ 251-255 (lines=5) @@
248
                    'pending' => false
249
                ]);
250
251
            if (null === $badgeCompletion) {
252
                $this->addFlash(
253
                    'error',
254
                    sprintf('%s has no badge named "%s"', $user->getUsername(), $badge->getTitle())
255
                );
256
257
                return $this->redirectToRoute('admin_unlocked_badge_remove');
258
            }