Passed
Push — master ( 7f699f...e24ab0 )
by Kirill
03:06
created

CallableRule::allows()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Security\Rule;
13
14
use Spiral\Security\ActorInterface;
15
use Spiral\Security\RuleInterface;
16
17
/**
18
 * Wraps callable expression.
19
 */
20
final class CallableRule implements RuleInterface
21
{
22
    /**
23
     * @var callable
24
     */
25
    private $callable = null;
26
27
    /**
28
     * @param callable $callable
29
     */
30
    public function __construct(callable $callable)
31
    {
32
        $this->callable = $callable;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function allows(ActorInterface $actor, string $permission, array $context): bool
39
    {
40
        return (bool)call_user_func($this->callable, $actor, $permission, $context);
41
    }
42
}
43