Code Duplication    Length = 19-19 lines in 2 locations

app/Auth/AccountManager/DatabaseAccountManager.php 1 location

@@ 34-52 (lines=19) @@
31
                ->getPassword() === $password;
32
    }
33
34
    public function getRole($accountId)
35
    {
36
        if ($this->isExistAccountId($accountId) === false) {
37
            return null;
38
        }
39
40
        $roles = DatabaseManager::getEntityManager()
41
                    ->getRepository(User::class)
42
                    ->findOneBy(['accountId' => $accountId])
43
                    ->getRoles();
44
45
        $roleArray = [];
46
47
        foreach ($roles as $item) {
48
            $roleArray[] = $item->getName();
49
        }
50
51
        return $roleArray;
52
    }
53
}
54

app/Auth/PermissionManager/DatabasePermissionManager.php 1 location

@@ 18-36 (lines=19) @@
15
    /**
16
     * @return array|null
17
     */
18
    public function getRolesByOperation($operation)
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