Completed
Push — master ( 2c882d...4a2271 )
by
unknown
07:55 queued 26s
created

Admin::canSwitchTo()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
1
<?php
2
3
namespace SumoCoders\FrameworkUserBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use SumoCoders\FrameworkMultiUserBundle\Entity\BaseUser;
7
8
/**
9
 * @ORM\Entity(repositoryClass="SumoCoders\FrameworkUserBundle\Repository\AdminRepository")
10
 * @ORM\Table()
11
 */
12
final class Admin extends User
13
{
14
    public function getRoles(): array
15
    {
16
        return ['ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'];
17
    }
18
19
    public function canSwitchTo(BaseUser $user): bool
20
    {
21
        return !($user instanceof self) && !$user->isBlocked();
22
    }
23
}
24