Code Duplication    Length = 19-21 lines in 4 locations

src/Surfnet/StepupRa/RaBundle/Service/RaLocationService.php 1 location

@@ 144-162 (lines=19) @@
141
     * @param RemoveRaLocationCommand $command
142
     * @return bool
143
     */
144
    public function remove(RemoveRaLocationCommand $command)
145
    {
146
        $middlewareCommand = new MiddlewareRemoveRaLocationCommand();
147
        $middlewareCommand->institution = $command->institution;
148
        $middlewareCommand->raLocationId = $command->locationId;
149
        $result = $this->commandService->execute($middlewareCommand);
150
151
        if (!$result->isSuccessful()) {
152
            $this->logger->critical(sprintf(
153
                'Removal of RA location "%s" of institution "%s" by user "%s" failed: "%s"',
154
                $middlewareCommand->raLocationId,
155
                $middlewareCommand->institution,
156
                $command->currentUserId,
157
                implode(", ", $result->getErrors())
158
            ));
159
        }
160
161
        return $result->isSuccessful();
162
    }
163
}
164

src/Surfnet/StepupRa/RaBundle/Service/RaService.php 2 locations

@@ 48-66 (lines=19) @@
45
        $this->logger = $logger;
46
    }
47
48
    public function amendRegistrationAuthorityInformation(AmendRegistrationAuthorityInformationCommand $command)
49
    {
50
        $apiCommand = new AmendRegistrationAuthorityInformationApiCommand();
51
        $apiCommand->identityId = $command->identityId;
52
        $apiCommand->location = $command->location;
53
        $apiCommand->contactInformation = $command->contactInformation;
54
55
        $result = $this->commandService->execute($apiCommand);
56
57
        if (!$result->isSuccessful()) {
58
            $this->logger->error(sprintf(
59
                "Amending of registration authority %s's information failed: '%s'",
60
                $apiCommand->identityId,
61
                implode("', '", $result->getErrors())
62
            ));
63
        }
64
65
        return $result->isSuccessful();
66
    }
67
68
    public function changeRegistrationAuthorityRole(ChangeRaRoleCommand $command)
69
    {
@@ 68-86 (lines=19) @@
65
        return $result->isSuccessful();
66
    }
67
68
    public function changeRegistrationAuthorityRole(ChangeRaRoleCommand $command)
69
    {
70
        $apiCommand             = new AppointRoleCommand();
71
        $apiCommand->identityId = $command->identityId;
72
        $apiCommand->role       = $command->role;
73
74
        $result = $this->commandService->execute($apiCommand);
75
76
        if (!$result->isSuccessful()) {
77
            $this->logger->error(sprintf(
78
                'Could not change Identity "%s" role to "%s": "%s"',
79
                $apiCommand->identityId,
80
                $apiCommand->role,
81
                implode("', '", $result->getErrors())
82
            ));
83
        }
84
85
        return $result->isSuccessful();
86
    }
87
88
    public function retractRegistrationAuthority(RetractRegistrationAuthorityCommand $command)
89
    {

src/Surfnet/StepupRa/RaBundle/Service/RaSecondFactorService.php 1 location

@@ 71-91 (lines=21) @@
68
        $this->logger = $logger;
69
    }
70
71
    public function revoke(RevokeSecondFactorCommand $command)
72
    {
73
        $middlewareCommand                 = new RevokeRegistrantsSecondFactorCommand();
74
        $middlewareCommand->secondFactorId = $command->secondFactorId;
75
        $middlewareCommand->identityId     = $command->identityId;
76
        $middlewareCommand->authorityId    = $command->currentUserId;
77
78
        $result = $this->commandService->execute($middlewareCommand);
79
80
        if (!$result->isSuccessful()) {
81
            $this->logger->critical(sprintf(
82
                'Revocation of Second Factor "%s" of Identity "%s" by user "%s" failed: "%s"',
83
                $middlewareCommand->secondFactorId,
84
                $middlewareCommand->identityId,
85
                $middlewareCommand->authorityId,
86
                implode(", ", $result->getErrors())
87
            ));
88
        }
89
90
        return $result->isSuccessful();
91
    }
92
93
    /**
94
     * @param SearchRaSecondFactorsCommand $command