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

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