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

DatabasePermissionManager::getRolesByOperation()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 10

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 19
loc 19
rs 9.4285
cc 3
eloc 10
nc 3
nop 1
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