Code Duplication    Length = 17-19 lines in 3 locations

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

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

src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/CommandHandler/InstitutionConfigurationCommandHandler.php 1 location

@@ 61-79 (lines=19) @@
58
        $this->repository = $repository;
59
    }
60
61
    public function handleCreateInstitutionConfigurationCommand(CreateInstitutionConfigurationCommand $command)
62
    {
63
        $institution = new Institution($command->institution);
64
        $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
65
66
        try {
67
            /** @var InstitutionConfiguration $institutionConfiguration */
68
            $institutionConfiguration = $this->repository->load(
69
                $institutionConfigurationId->getInstitutionConfigurationId()
70
            );
71
72
            $institutionConfiguration->rebuild();
73
        } catch (AggregateNotFoundException $exception) {
74
            $institutionConfiguration = InstitutionConfiguration::create($institutionConfigurationId, $institution);
75
        }
76
77
        $this->repository->save($institutionConfiguration);
78
    }
79
80
    public function handleReconfigureInstitutionConfigurationOptionsCommand(
81
        ReconfigureInstitutionConfigurationOptionsCommand $command
82
    ) {

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

@@ 450-466 (lines=17) @@
447
     * @param Institution $institution
448
     * @return InstitutionConfiguration
449
     */
450
    private function loadInstitutionConfigurationFor(Institution $institution)
451
    {
452
        $institution = new ConfigurationInstitution($institution->getInstitution());
453
        try {
454
            $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
455
            $institutionConfiguration = $this->institutionConfigurationRepository->load(
456
                $institutionConfigurationId->getInstitutionConfigurationId()
457
            );
458
        } catch (AggregateNotFoundException $exception) {
459
            $institutionConfigurationId = InstitutionConfigurationId::from($institution);
460
            $institutionConfiguration = $this->institutionConfigurationRepository->load(
461
                $institutionConfigurationId->getInstitutionConfigurationId()
462
            );
463
        }
464
465
        return $institutionConfiguration;
466
    }
467
}
468