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 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10

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 Symnedi.
7
 * Copyright (c) 2014 Tomas Votruba (http://tomasvotruba.cz)
8
 */
9
10
namespace Symnedi\Security\EventSubscriber;
11
12
use Nette\Application\UI\ComponentReflection;
13
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
14
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
15
use Symnedi\EventDispatcher\Event\ApplicationPresenterEvent;
16
use Symnedi\EventDispatcher\NetteApplicationEvents;
17
18
final class CheckRequirementsSubscriber implements EventSubscriberInterface
19
{
20
    /**
21
     * @var AuthorizationCheckerInterface
22
     */
23
    private $authorizationChecker;
24
25 1
    public function __construct(AuthorizationCheckerInterface $authorizationChecker)
26
    {
27 1
        $this->authorizationChecker = $authorizationChecker;
28 1
    }
29
30 1
    public static function getSubscribedEvents() : array
31
    {
32
        return [
33 1
            NetteApplicationEvents::ON_PRESENTER => 'onPresenter',
34
        ];
35
    }
36
37 1
    public function onPresenter(ApplicationPresenterEvent $applicationPresenterEvent)
38
    {
39 1
        $this->authorizationChecker->isGranted(
40 1
            'access',
41 1
            new ComponentReflection($applicationPresenterEvent->getPresenter())
42
        );
43 1
    }
44
}
45