Completed
Push — master ( 070a1e...ccce77 )
by Anton
12s
created

Acl::isAllowed()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.072

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 2
dl 0
loc 8
ccs 4
cts 5
cp 0.8
crap 3.072
rs 9.4285
c 0
b 0
f 0
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 3
    public function isAllowed($module, $privilege) : bool
36
    {
37 3
        if ($privilege) {
38 3
            $user = Auth::getIdentity();
39 3
            return $user && $user->hasPrivilege($module, $privilege);
40
        }
41
        return true;
42
    }
43
}
44