Code Duplication    Length = 5-8 lines in 3 locations

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

@@ 131-138 (lines=8) @@
128
            $token = new UsernamePasswordToken($user, 'none', 'none', $user->getRoles());
129
            $isUnlockable = $this->get('security.access.public_decision_manager')->decide($token, ['view'], $badge);
130
131
            if (!$isUnlockable) {
132
                $this->addFlash(
133
                    'error',
134
                    sprintf('%s does not have access to badge "%s"', $user->getUsername(), $badge->getTitle())
135
                );
136
137
                return $this->redirectToRoute('admin_unlocked_badge_give');
138
            }
139
140
            $badgeCompletion = $this->get('badger.game.repository.badge_completion')
141
                ->findOneBy([
@@ 150-157 (lines=8) @@
147
                $badgeCompletion = $this->get('badger.game.badge_completion.factory')->create($user, $badge);
148
            }
149
150
            if (!$badgeCompletion->isPending()) {
151
                $this->addFlash(
152
                    'error',
153
                    sprintf('%s already has the badge "%s"', $user->getUsername(), $badge->getTitle())
154
                );
155
156
                return $this->redirectToRoute('admin_unlocked_badge_give');
157
            }
158
159
            $badgeCompletion->setPending(false);
160
            $badgeCompletion->setCompletionDate(new \DateTime());
@@ 211-215 (lines=5) @@
208
                    'pending' => false
209
                ]);
210
211
            if (null === $badgeCompletion) {
212
                $this->addFlash(
213
                    'error',
214
                    sprintf('%s has no badge named "%s"', $user->getUsername(), $badge->getTitle())
215
                );
216
217
                return $this->redirectToRoute('admin_unlocked_badge_remove');
218
            }