Code Duplication    Length = 15-15 lines in 2 locations

src/Traits/HasRoles.php 1 location

@@ 89-103 (lines=15) @@
86
     *
87
     * @return array|Role|string
88
     */
89
    public function removeRole(...$roles)
90
    {
91
        \collect($roles)
92
            ->flatten()
93
            ->map(function ($role) {
94
                $role = $this->getStoredRole($role);
95
                $this->roles()->detach($role);
96
97
                return $role;
98
            });
99
100
        $this->forgetCachedPermissions();
101
102
        return $roles;
103
    }
104
105
    /**
106
     * Remove all current roles and set the given ones.

src/Traits/HasPermissions.php 1 location

@@ 106-120 (lines=15) @@
103
     * @return $this
104
     * @throws \Maklad\Permission\Exceptions\GuardDoesNotMatch
105
     */
106
    public function revokePermissionTo(...$permissions)
107
    {
108
        collect($permissions)
109
            ->flatten()
110
            ->map(function ($permission) {
111
                $permission = $this->getStoredPermission($permission);
112
                $this->permissions()->detach($permission);
113
114
                return $permission;
115
            });
116
117
        $this->forgetCachedPermissions();
118
119
        return $this;
120
    }
121
122
    /**
123
     * @param string|Permission $permission