Code Duplication    Length = 13-17 lines in 4 locations

src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/CommandHandler/InstitutionConfigurationCommandHandler.php 2 locations

@@ 166-178 (lines=13) @@
163
        $this->repository->save($institutionConfiguration);
164
    }
165
166
    public function handleRemoveInstitutionConfigurationByUnnormalizedIdCommand(
167
        RemoveInstitutionConfigurationByUnnormalizedIdCommand $command
168
    ) {
169
        $institution = new Institution($command->institution);
170
171
        $institutionConfigurationId = InstitutionConfigurationId::from($institution);
172
        $institutionConfiguration = $this->repository->load(
173
            $institutionConfigurationId->getInstitutionConfigurationId()
174
        );
175
        $institutionConfiguration->destroy();
176
177
        $this->repository->save($institutionConfiguration);
178
    }
179
180
    /**
181
     * @deprecated Should be used until existing institution configurations have been migrated to using normalized ids
@@ 186-201 (lines=16) @@
183
     * @param Institution $institution
184
     * @return InstitutionConfiguration
185
     */
186
    private function loadInstitutionConfigurationFor(Institution $institution)
187
    {
188
        try {
189
            $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
190
            $institutionConfiguration = $this->repository->load(
191
                $institutionConfigurationId->getInstitutionConfigurationId()
192
            );
193
        } catch (AggregateNotFoundException $exception) {
194
            $institutionConfigurationId = InstitutionConfigurationId::from($institution);
195
            $institutionConfiguration = $this->repository->load(
196
                $institutionConfigurationId->getInstitutionConfigurationId()
197
            );
198
        }
199
200
        return $institutionConfiguration;
201
    }
202
}
203

src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/IdentityCommandHandler.php 1 location

@@ 437-453 (lines=17) @@
434
     * @param Institution $institution
435
     * @return InstitutionConfiguration
436
     */
437
    private function loadInstitutionConfigurationFor(Institution $institution)
438
    {
439
        $institution = new ConfigurationInstitution($institution->getInstitution());
440
        try {
441
            $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
442
            $institutionConfiguration = $this->institutionConfigurationRepository->load(
443
                $institutionConfigurationId->getInstitutionConfigurationId()
444
            );
445
        } catch (AggregateNotFoundException $exception) {
446
            $institutionConfigurationId = InstitutionConfigurationId::from($institution);
447
            $institutionConfiguration = $this->institutionConfigurationRepository->load(
448
                $institutionConfigurationId->getInstitutionConfigurationId()
449
            );
450
        }
451
452
        return $institutionConfiguration;
453
    }
454
}
455

src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/RegistrationAuthorityCommandHandler.php 1 location

@@ 147-163 (lines=17) @@
144
     * @param Institution $institution
145
     * @return InstitutionConfiguration
146
     */
147
    private function loadInstitutionConfigurationFor(Institution $institution)
148
    {
149
        $institution = new ConfigurationInstitution($institution->getInstitution());
150
        try {
151
            $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
152
            $institutionConfiguration = $this->institutionConfigurationRepository->load(
153
                $institutionConfigurationId->getInstitutionConfigurationId()
154
            );
155
        } catch (AggregateNotFoundException $exception) {
156
            $institutionConfigurationId = InstitutionConfigurationId::from($institution);
157
            $institutionConfiguration = $this->institutionConfigurationRepository->load(
158
                $institutionConfigurationId->getInstitutionConfigurationId()
159
            );
160
        }
161
162
        return $institutionConfiguration;
163
    }
164
}
165