Admin::getRoles()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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
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);
0 ignored issues
show
Bug introduced by
It seems like $token defined by parameter $token on line 20 can also be of type object<SumoCoders\Framew...ity\PasswordResetToken>; however, SumoCoders\FrameworkMult...BaseUser::__construct() does only seem to accept null|integer, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
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