UserTrait::newUserPrivileges()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Lagdo\DbAdmin\Db\Driver\Facades;
4
5
/**
6
 * Facade to user functions
7
 */
8
trait UserTrait
9
{
10
    use AbstractTrait;
11
12
    /**
13
     * Get the facade to user features
14
     *
15
     * @return UserFacade
16
     */
17
    protected function userFacade(): UserFacade
18
    {
19
        return $this->di()->g(UserFacade::class);
20
    }
21
22
    /**
23
     * Get the privilege list
24
     * This feature is available only for MySQL
25
     *
26
     * @param string $database  The database name
27
     *
28
     * @return array
29
     */
30
    public function getPrivileges(string $database = ''): array
31
    {
32
        $this->connectToServer();
33
        $this->breadcrumbs()->clear()->item($this->utils->trans->lang('Privileges'));
34
        return $this->userFacade()->getPrivileges($database);
35
    }
36
37
    /**
38
     * Get the privileges for a new user
39
     *
40
     * @return array
41
     */
42
    public function newUserPrivileges(): array
43
    {
44
        $this->connectToServer();
45
        return $this->userFacade()->newUserPrivileges();
46
    }
47
48
    /**
49
     * Get the privileges for a new user
50
     *
51
     * @param string $user      The user name
52
     * @param string $host      The host name
53
     * @param string $database  The database name
54
     *
55
     * @return array
56
     */
57
    public function getUserPrivileges(string $user, string $host, string $database): array
58
    {
59
        $this->connectToServer();
60
        return $this->userFacade()->getUserPrivileges($user, $host, $database);
61
    }
62
}
63