Code Duplication    Length = 10-11 lines in 3 locations

src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapIdentityCommand.php 1 location

@@ 62-71 (lines=10) @@
59
        $this->enrichEventMetadata($actorId);
60
61
        $output->writeln(sprintf('<comment>Adding an identity named: %s</comment>', $commonName));
62
        if ($this->tokenBootstrapService->hasIdentityWithNameIdAndInstitution($nameId, $institution)) {
63
            $output->writeln(
64
                sprintf(
65
                    '<error>An identity with name ID "%s" from institution "%s" already exists</error>',
66
                    $nameId->getNameId(),
67
                    $institution->getInstitution()
68
                )
69
            );
70
            return;
71
        }
72
        try {
73
            $this->beginTransaction();
74
            $output->writeln('<info>Creating a new identity</info>');

src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapIdentityWithYubikeySecondFactorCommand.php 1 location

@@ 64-74 (lines=11) @@
61
        $nameId      = new NameId($input->getArgument('name-id'));
62
        $institution = new Institution($input->getArgument('institution'));
63
64
        if ($projectionRepository->hasIdentityWithNameIdAndInstitution($nameId, $institution)) {
65
            $output->writeln(
66
                sprintf(
67
                    '<error>An identity with name ID "%s" from institution "%s" already exists</error>',
68
                    $nameId->getNameId(),
69
                    $institution->getInstitution()
70
                )
71
            );
72
73
            return 1;
74
        }
75
76
        $command                  = new BootstrapIdentityWithYubikeySecondFactorIdentityCommand();
77
        $command->UUID            = (string) Uuid::uuid4();

src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapSmsSecondFactorCommand.php 1 location

@@ 67-77 (lines=11) @@
64
        $phoneNumber = $input->getArgument('phone-number');
65
        $actorId = $input->getArgument('actor-id');
66
        $this->enrichEventMetadata($actorId);
67
        if (!$this->tokenBootstrapService->hasIdentityWithNameIdAndInstitution($nameId, $institution)) {
68
            $output->writeln(
69
                sprintf(
70
                    '<error>An identity with name ID "%s" from institution "%s" does not exist, create it first.</error>',
71
                    $nameId->getNameId(),
72
                    $institution->getInstitution()
73
                )
74
            );
75
76
            return;
77
        }
78
        $identity = $this->tokenBootstrapService->findOneByNameIdAndInstitution($nameId, $institution);
79
        $output->writeln(sprintf('<comment>Adding a %s SMS token for %s</comment>', $registrationStatus, $identity->commonName));
80
        $this->beginTransaction();