CheckRequirementsSubscriber   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSubscribedEvents() 0 6 1
A onPresenter() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Symplify.
7
 * Copyright (c) 2014 Tomas Votruba (http://tomasvotruba.cz)
8
 */
9
10
namespace Symplify\SymfonySecurity\EventSubscriber;
11
12
use Nette\Application\UI\ComponentReflection;
13
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
14
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
15
use Symplify\SymfonyEventDispatcher\Adapter\Nette\Event\PresenterCreatedEvent;
16
17
final class CheckRequirementsSubscriber implements EventSubscriberInterface
18
{
19
    /**
20
     * @var AuthorizationCheckerInterface
21
     */
22
    private $authorizationChecker;
23
24 1
    public function __construct(AuthorizationCheckerInterface $authorizationChecker)
25
    {
26 1
        $this->authorizationChecker = $authorizationChecker;
27 1
    }
28
29 1
    public static function getSubscribedEvents() : array
30
    {
31
        return [
32 1
            PresenterCreatedEvent::NAME => 'onPresenter',
33
        ];
34
    }
35
36 1
    public function onPresenter(PresenterCreatedEvent $applicationPresenterEvent)
37
    {
38 1
        $this->authorizationChecker->isGranted(
39 1
            'access',
40 1
            new ComponentReflection($applicationPresenterEvent->getPresenter())
41
        );
42 1
    }
43
}
44