Completed
Branch feature/pre-split (197e7e)
by Anton
03:26
created

CallableRule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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