Code Duplication    Length = 10-12 lines in 4 locations

src/Surfnet/StepupMiddleware/ApiBundle/Configuration/EventListener/IdentityEventListener.php 1 location

@@ 46-55 (lines=10) @@
43
        $this->institutionConfigurationCreationService = $institutionConfigurationCreationService;
44
    }
45
46
    public function applyIdentityCreatedEvent(IdentityCreatedEvent $event)
47
    {
48
        $institution = new Institution($event->identityInstitution->getInstitution());
49
50
        if ($this->configuredInstitutionRepository->hasConfigurationFor($institution)) {
51
            return;
52
        }
53
54
        $this->institutionConfigurationCreationService->createConfigurationFor($institution);
55
    }
56
}
57

src/Surfnet/StepupMiddleware/ApiBundle/Configuration/EventListener/WhitelistEventListener.php 3 locations

@@ 48-59 (lines=12) @@
45
        $this->institutionConfigurationCreationService = $institutionConfigurationCreationService;
46
    }
47
48
    public function applyWhitelistCreatedEvent(WhitelistCreatedEvent $event)
49
    {
50
        foreach ($event->whitelistedInstitutions as $whitelistedInstitution) {
51
            $institution = new Institution($whitelistedInstitution->getInstitution());
52
53
            if ($this->configuredInstitutionRepository->hasConfigurationFor($institution)) {
54
                continue;
55
            }
56
57
            $this->institutionConfigurationCreationService->createConfigurationFor($institution);
58
        }
59
    }
60
61
    public function applyWhitelistReplacedEvent(WhitelistReplacedEvent $event)
62
    {
@@ 61-72 (lines=12) @@
58
        }
59
    }
60
61
    public function applyWhitelistReplacedEvent(WhitelistReplacedEvent $event)
62
    {
63
        foreach ($event->whitelistedInstitutions as $whitelistedInstitution) {
64
            $institution = new Institution($whitelistedInstitution->getInstitution());
65
66
            if ($this->configuredInstitutionRepository->hasConfigurationFor($institution)) {
67
                continue;
68
            }
69
70
            $this->institutionConfigurationCreationService->createConfigurationFor($institution);
71
        }
72
    }
73
74
    public function applyInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhitelistEvent $event)
75
    {
@@ 74-85 (lines=12) @@
71
        }
72
    }
73
74
    public function applyInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhitelistEvent $event)
75
    {
76
        foreach ($event->addedInstitutions as $addedInstitution) {
77
            $institution = new Institution($addedInstitution->getInstitution());
78
79
            if ($this->configuredInstitutionRepository->hasConfigurationFor($institution)) {
80
                continue;
81
            }
82
83
            $this->institutionConfigurationCreationService->createConfigurationFor($institution);
84
        }
85
    }
86
}
87