Completed
Push — master ( 419843...f5da21 )
by Anton
14s
created

Acl   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A isAllowed() 0 8 3
1
<?php
2
/**
3
 * Bluz Framework Component
4
 *
5
 * @copyright Bluz PHP Team
6
 * @link      https://github.com/bluzphp/framework
7
 */
8
9
declare(strict_types=1);
10
11
namespace Bluz\Acl;
12
13
use Bluz\Common\Options;
14
use Bluz\Proxy\Auth;
15
16
/**
17
 * Acl
18
 *
19
 * @package  Bluz\Acl
20
 * @author   Anton Shevchuk
21
 * @link     https://github.com/bluzphp/framework/wiki/Acl
22
 */
23
class Acl
24
{
25
    use Options;
26
27
    /**
28
     * Check user access by pair module-privilege
29
     *
30
     * @param  string $module
31
     * @param  string $privilege
32
     *
33
     * @return bool
34
     */
35 18
    public function isAllowed($module, $privilege): bool
36
    {
37 18
        if ($privilege) {
38 5
            $user = Auth::getIdentity();
39 5
            return $user && $user->hasPrivilege($module, $privilege);
40
        }
41 13
        return true;
42
    }
43
}
44