Admin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

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
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