Completed
Push — master ( 03841e...c8ea4b )
by Sherif
05:27
created

GroupRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 33.33 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 1
dl 10
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getModel() 0 4 1
A assignPermissions() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace App\Modules\Acl\Repositories;
2
3
use App\Modules\Core\AbstractRepositories\AbstractRepository;
4
5
class GroupRepository extends AbstractRepository
6
{
7
	/**
8
	 * Return the model full namespace.
9
	 * 
10
	 * @return string
11
	 */
12
	protected function getModel()
13
	{
14
		return 'App\Modules\Acl\AclGroup';
15
	}
16
17
	/**
18
	 * Assign the given permission ids to the given group.
19
	 * 
20
	 * @param  integer $group_id    
21
	 * @param  array   $permission_ids
22
	 * @return object
23
	 */
24 View Code Duplication
	public function assignPermissions($group_id, $permission_ids)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
	{
26
		\DB::transaction(function () use ($group_id, $permission_ids) {
27
			$group = \Core::groups()->find($group_id);
28
			$group->permissions()->detach();
29
			$group->permissions()->attach($permission_ids);
30
		});
31
32
        return \Core::groups()->find($group_id);
33
	}
34
}
35