Code Duplication    Length = 12-13 lines in 3 locations

Controller/TenantUserController.php 3 locations

@@ 88-100 (lines=13) @@
85
    /**
86
     * @param array $userIdRole Must follow the pattern userId => Role, array(1=> 'ROLE_ADMIN')
87
     */
88
    protected function promoteUsers($userIdRole) {
89
90
        $tenantUserHandler = $this->container->get('tahoe.multi_tenancy.tenant_user_handler');
91
        $userRepository = $this->container->get('user_repository');
92
93
        $tenant = $this->container->get('tahoe.multi_tenancy.tenant_resolver')->getTenant();
94
95
        foreach ($userIdRole as $userId => $role) {
96
97
            $user = $userRepository->find($userId);
98
            $tenantUserHandler->addRoleToUserInTenant($role, $user, $tenant);
99
        }
100
    }
101
102
    /**
103
     * @param array $userIdRole Must follow the pattern userId => Role, array(1=> 'ROLE_ADMIN')
@@ 105-117 (lines=13) @@
102
    /**
103
     * @param array $userIdRole Must follow the pattern userId => Role, array(1=> 'ROLE_ADMIN')
104
     */
105
    protected function demoteUsers($userIdRole) {
106
107
        $tenantUserHandler = $this->container->get('tahoe.multi_tenancy.tenant_user_handler');
108
        $userRepository = $this->container->get('user_repository');
109
110
        $tenant = $this->container->get('tahoe.multi_tenancy.tenant_resolver')->getTenant();
111
112
        foreach ($userIdRole as $userId => $role) {
113
114
            $user = $userRepository->find($userId);
115
            $tenantUserHandler->removeRoleFromUserInTenant($role, $user, $tenant);
116
        }
117
    }
118
119
    /**
120
     * @param array $userIdRole Must follow the pattern userId => ignored, array(1=> 'anything')
@@ 122-133 (lines=12) @@
119
    /**
120
     * @param array $userIdRole Must follow the pattern userId => ignored, array(1=> 'anything')
121
     */
122
    protected function removeUsers($userIdRole) {
123
        $tenantUserHandler = $this->container->get('tahoe.multi_tenancy.tenant_user_handler');
124
        $userRepository = $this->container->get('user_repository');
125
126
        $tenant = $this->container->get('tahoe.multi_tenancy.tenant_resolver')->getTenant();
127
128
        foreach ($userIdRole as $userId => $dummy) {
129
130
            $user = $userRepository->find($userId);
131
            $tenantUserHandler->removeUserFromTenant($user, $tenant);
132
        }
133
    }
134
}
135