Code Duplication    Length = 18-19 lines in 2 locations

src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SecondFactorService.php 2 locations

@@ 232-250 (lines=19) @@
229
     * @param string $verificationNonce
230
     * @return UnverifiedSecondFactor|null
231
     */
232
    public function findUnverifiedByVerificationNonce($identityId, $verificationNonce)
233
    {
234
        $secondFactors = $this->secondFactors->searchUnverified(
235
            (new UnverifiedSecondFactorSearchQuery())
236
                ->setIdentityId($identityId)
237
                ->setVerificationNonce($verificationNonce)
238
        );
239
240
        $elements = $secondFactors->getElements();
241
242
        switch (count($elements)) {
243
            case 0:
244
                return null;
245
            case 1:
246
                return reset($elements);
247
            default:
248
                throw new LogicException('There cannot be more than one unverified second factor with the same nonce');
249
        }
250
    }
251
252
    /**
253
     * @param string $secondFactorId
@@ 257-274 (lines=18) @@
254
     * @param string $identityId
255
     * @return null|string
256
     */
257
    public function getRegistrationCode($secondFactorId, $identityId)
258
    {
259
        $query = (new VerifiedSecondFactorSearchQuery())
260
            ->setIdentityId($identityId)
261
            ->setSecondFactorId($secondFactorId);
262
263
        /** @var VerifiedSecondFactor[] $verifiedSecondFactors */
264
        $verifiedSecondFactors = $this->secondFactors->searchVerified($query)->getElements();
265
266
        switch (count($verifiedSecondFactors)) {
267
            case 0:
268
                return null;
269
            case 1:
270
                return reset($verifiedSecondFactors)->registrationCode;
271
            default:
272
                throw new LogicException('Searching by second factor ID cannot result in multiple results.');
273
        }
274
    }
275
276
    /**
277
     * @param array $allSecondFactors