Code Duplication    Length = 15-16 lines in 2 locations

src/Surfnet/StepupRa/RaBundle/Security/Authorization/Voter/AllowedInOtherInstitutionVoter.php 1 location

@@ 124-139 (lines=16) @@
121
        return $supportedClass === $class;
122
    }
123
124
    private function authorizedByRole(array $roles)
125
    {
126
        // The role requirements to VIEW_AUDITLOG, one of these roles must be met
127
        $allowedRoles = ['ROLE_SRAA', 'ROLE_RAA', 'ROLE_RA'];
128
129
        // Convert the Role[] to an array of strings representing the role names.
130
        $roles = array_map(
131
            function (Role $role) {
132
                return $role->getRole();
133
            },
134
            $roles
135
        );
136
137
        // And test if there is an intersection (is one or more of the token roles also in the allowed roles)
138
        return count(array_intersect($roles, $allowedRoles)) > 0;
139
    }
140
}
141

src/Surfnet/StepupRa/RaBundle/Security/Authorization/Voter/AllowedToSwitchInstitutionVoter.php 1 location

@@ 87-101 (lines=15) @@
84
        return in_array($attribute, [self::RAA_SWITCHING]);
85
    }
86
87
    private function authorizedByRole(array $roles)
88
    {
89
        $allowedRoles = ['ROLE_SRAA', 'ROLE_RAA'];
90
91
        // Convert the Role[] to an array of strings representing the role names.
92
        $roles = array_map(
93
            function (Role $role) {
94
                return $role->getRole();
95
            },
96
            $roles
97
        );
98
99
        // And test if there is an intersection (is one or more of the token roles also in the allowed roles)
100
        return count(array_intersect($roles, $allowedRoles)) > 0;
101
    }
102
}
103