Code Duplication    Length = 12-12 lines in 4 locations

src/Platfourm/User/Models/Eloquent/Traits/RoleTrait.php 2 locations

@@ 145-156 (lines=12) @@
142
     * @param  object|array $permission
143
     * @return void
144
     */
145
    public function attachPermission($permission)
146
    {
147
        if (is_object($permission)) {
148
            $permission = $permission->getKey();
149
        }
150
151
        if (is_array($permission)) {
152
            $permission = $permission['id'];
153
        }
154
155
        $this->perms()->attach($permission);
156
    }
157
158
    /**
159
     * Detach permission from current role.
@@ 164-175 (lines=12) @@
161
     * @param  object|array $permission
162
     * @return void
163
     */
164
    public function detachPermission($permission)
165
    {
166
        if (is_object($permission)) {
167
            $permission = $permission->getKey();
168
        }
169
170
        if (is_array($permission)) {
171
            $permission = $permission['id'];
172
        }
173
174
        $this->perms()->detach($permission);
175
    }
176
177
    /**
178
     * Attach multiple permissions to current role.

src/Platfourm/User/Models/Eloquent/Traits/UserTrait.php 2 locations

@@ 198-209 (lines=12) @@
195
     *
196
     * @param mixed $role
197
     */
198
    public function attachRole($role)
199
    {
200
        if (is_object($role)) {
201
            $role = $role->getKey();
202
        }
203
204
        if (is_array($role)) {
205
            $role = $role['id'];
206
        }
207
208
        $this->role->attach($role);
209
    }
210
211
    /**
212
     * Alias to eloquent many-to-many relation's detach() method.
@@ 216-227 (lines=12) @@
213
     *
214
     * @param mixed $role
215
     */
216
    public function detachRole($role)
217
    {
218
        if (is_object($role)) {
219
            $role = $role->getKey();
220
        }
221
222
        if (is_array($role)) {
223
            $role = $role['id'];
224
        }
225
226
        $this->role->detach($role);
227
    }
228
229
    /**
230
     * Attach multiple roles to a user