Code Duplication    Length = 5-8 lines in 3 locations

src/Badger/Bundle/GameBundle/Controller/ClaimedBadgeController.php 1 location

@@ 86-93 (lines=8) @@
83
                'badge' => $badge
84
            ]);
85
86
        if ($isUnlocked) {
87
            $this->addFlash(
88
                'error',
89
                sprintf(
90
                    '%s already has the badge "%s"',
91
                    $user->getUsername(),
92
                    $badge->getTitle()
93
                )
94
            );
95
96
            return $this->redirectToRoute('admin_claimed_badge_index');

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

@@ 143-150 (lines=8) @@
140
                    ->create($user, $badge);
141
            }
142
143
            if (!$badgeCompletion->isPending()) {
144
                $this->addFlash('error', sprintf('%s already has the badge "%s"',
145
                    $user->getUsername(),
146
                    $badge->getTitle()
147
                ));
148
149
                return $this->redirectToRoute('admin_unlocked_badge_give');
150
            }
151
152
            $badgeCompletion->setPending(false);
153
            $badgeCompletion->setCompletionDate(new \DateTime());
@@ 201-205 (lines=5) @@
198
                    'pending' => false
199
                ]);
200
201
            if (null === $badgeCompletion) {
202
                $this->addFlash('error', sprintf('%s has no badge named "%s"', $user->getUsername(), $badge->getTitle()));
203
204
                return $this->redirectToRoute('admin_unlocked_badge_remove');
205
            }
206
207
            $badgeCompletionRemover = $this->get('badger.game.remover.badge_completion');
208
            $badgeCompletionRemover->remove($badgeCompletion);