FirewallHandler   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFirewallName() 0 4 1
A handle() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Symplify\SymfonySecurity\Tests\Adapter\Nette\DI\SymfonySecurityExtension\FirewallSource;
6
7
use Nette\Application\AbortException;
8
use Nette\Application\Application;
9
use Nette\Http\IRequest;
10
use Nette\Security\User;
11
use Symplify\SymfonySecurity\Contract\Http\FirewallHandlerInterface;
12
13
final class FirewallHandler implements FirewallHandlerInterface
14
{
15
    /**
16
     * @var User
17
     */
18
    private $user;
19
20
    public function __construct(User $user)
21
    {
22
        $this->user = $user;
23
    }
24
25
    public function getFirewallName() : string
26
    {
27
        return 'adminFirewall';
28
    }
29
30
    public function handle(Application $application, IRequest $request)
31
    {
32
        if (! $this->user->isLoggedIn()) {
33
            throw new AbortException();
34
        }
35
36
        if (! $this->user->isInRole('admin')) {
37
            throw new AbortException();
38
        }
39
    }
40
}
41