InsecureRule   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A allows() 0 12 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
9
namespace Spiral\Vault\Security;
10
11
use Psr\Log\LogLevel;
12
use Spiral\Core\Component;
13
use Spiral\Debug\Traits\LoggerTrait;
14
use Spiral\Security\ActorInterface;
15
use Spiral\Security\RuleInterface;
16
17
/**
18
 * Rule with ability to raise alert message on granting access. Only for development environment.
19
 */
20
class InsecureRule extends Component implements RuleInterface
21
{
22
    use LoggerTrait;
23
24
    /**
25
     * Default log level.
26
     */
27
    const LEVEL = LogLevel::CRITICAL;
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function allows(ActorInterface $actor, string $permission, array $context): bool
33
    {
34
        $this->getLogger()->log(
35
            static::LEVEL,
36
            "Actor `{actor}` has been granted insecure access to '{permission}'.", [
37
                'actor'      => get_class($actor),
38
                'permission' => $permission
39
            ]
40
        );
41
42
        return true;
43
    }
44
}