Completed
Push — master ( 5e3948...6ee39d )
by Park Jong-Hun
03:40
created

DatabasePermissionManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 65.52 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 4
dl 19
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getRolesByOperation() 19 19 3

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
2
3
namespace App\Auth\PermissionManager;
4
5
use App\Auth\PermissionManager;
6
use App\Entity\Permission;
7
use Core\DatabaseManager;
8
9
class DatabasePermissionManager extends PermissionManager
10
{
11
    public function __construct($settings = [])
12
    {
13
    }
14
15
    /**
16
     * @return array|null
17
     */
18 View Code Duplication
    public function getRolesByOperation($operation)
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...
19
    {
20
        $roleArray = [];
21
22
        /** @var Permission */
23
        $permission = DatabaseManager::getEntityManager()
24
                        ->getRepository(Permission::class)
25
                        ->findOneBy(['operation' => $operation]);
26
27
        if ($permission === null) {
28
            return null;
29
        }
30
31
        foreach ($permission->getRoles() as $item) {
32
            $roleArray[] = $item->getName();
33
        }
34
35
        return $roleArray;
36
    }
37
}
38