Code Duplication    Length = 18-21 lines in 5 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/RaSecondFactorService.php 1 location

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

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

@@ 48-67 (lines=20) @@
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
        $apiCommand->raInstitution = $command->institution;
55
56
        $result = $this->commandService->execute($apiCommand);
57
58
        if (!$result->isSuccessful()) {
59
            $this->logger->error(sprintf(
60
                "Amending of registration authority %s's information failed: '%s'",
61
                $apiCommand->identityId,
62
                implode("', '", $result->getErrors())
63
            ));
64
        }
65
66
        return $result->isSuccessful();
67
    }
68
69
    public function changeRegistrationAuthorityRole(ChangeRaRoleCommand $command)
70
    {
@@ 69-87 (lines=19) @@
66
        return $result->isSuccessful();
67
    }
68
69
    public function changeRegistrationAuthorityRole(ChangeRaRoleCommand $command)
70
    {
71
        $apiCommand             = new AppointRoleCommand();
72
        $apiCommand->identityId = $command->identityId;
73
        $apiCommand->role       = $command->role;
74
75
        $result = $this->commandService->execute($apiCommand);
76
77
        if (!$result->isSuccessful()) {
78
            $this->logger->error(sprintf(
79
                'Could not change Identity "%s" role to "%s": "%s"',
80
                $apiCommand->identityId,
81
                $apiCommand->role,
82
                implode("', '", $result->getErrors())
83
            ));
84
        }
85
86
        return $result->isSuccessful();
87
    }
88
89
    public function retractRegistrationAuthority(RetractRegistrationAuthorityCommand $command)
90
    {
@@ 89-106 (lines=18) @@
86
        return $result->isSuccessful();
87
    }
88
89
    public function retractRegistrationAuthority(RetractRegistrationAuthorityCommand $command)
90
    {
91
        $apiCommand              = new ApiRetractRegistrationAuthorityCommand();
92
        $apiCommand->identityId  = $command->identityId;
93
        $apiCommand->institution = $command->institution;
94
95
        $result = $this->commandService->execute($apiCommand);
96
97
        if (!$result->isSuccessful()) {
98
            $this->logger->error(sprintf(
99
                'Could not retract registration authority for identity "%s": "%s"',
100
                $apiCommand->identityId,
101
                implode("', '", $result->getErrors())
102
            ));
103
        }
104
105
        return $result->isSuccessful();
106
    }
107
}
108