Completed
Push — master ( 4a2271...f643c6 )
by
unknown
14s
created

Admin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 22
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getRoles() 0 4 1
A canSwitchTo() 0 4 2
1
<?php
2
3
namespace SumoCoders\FrameworkUserBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use SumoCoders\FrameworkMultiUserBundle\Entity\BaseUser;
7
use SumoCoders\FrameworkMultiUserBundle\Security\PasswordResetToken;
8
9
/**
10
 * @ORM\Entity(repositoryClass="SumoCoders\FrameworkUserBundle\Repository\AdminRepository")
11
 * @ORM\Table()
12
 */
13
final class Admin extends BaseUser
14
{
15
    public function __construct(
16
        string $plainPassword,
17
        string $displayName,
18
        string $email,
19
        int $id = null,
20
        PasswordResetToken $token = null
21
    ) {
22
        parent::__construct($email, $plainPassword, $displayName, $email, $id, $token);
23
    }
24
25
    public function getRoles(): array
26
    {
27
        return ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'];
28
    }
29
30
    public function canSwitchTo(BaseUser $user): bool
31
    {
32
        return !($user instanceof self) && !$user->isBlocked();
33
    }
34
}
35