Completed
Push — SF4 ( a8e33f...5cf220 )
by Laurent
03:08
created

User   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 2
dl 0
loc 52
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 4 1
A getRoles() 0 8 1
A isEqualTo() 0 14 3
1
<?php
2
3
/**
4
 * Entity User.
5
 *
6
 * PHP Version 7
7
 *
8
 * @author    Quétier Laurent <[email protected]>
9
 * @copyright 2018 Dev-Int GLSR
10
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version GIT: $Id$
13
 *
14
 * @link https://github.com/Dev-Int/glsr
15
 */
16
17
namespace App\Entity\Staff;
18
19
use Doctrine\ORM\Mapping as ORM;
20
use FOS\UserBundle\Model\User as BaseUser;
21
use Symfony\Component\Security\Core\User\UserInterface;
22
use Symfony\Component\Security\Core\User\EquatableInterface;
23
24
/**
25
 * User Entity.
26
 *
27
 * @category Entity
28
 *
29
 * @ORM\Table(name="fos_users")
30
 * @ORM\Entity(repositoryClass="App\Repository\Staff\UserRepository")
31
 */
32
class User extends BaseUser implements UserInterface, EquatableInterface
33
{
34
    /**
35
     * @ORM\Id
36
     * @ORM\Column(type="integer")
37
     * @ORM\GeneratedValue(strategy="AUTO")
38
     */
39
    protected $id;
40
41
    /**
42
     * User constructor.
43
     */
44
    public function __construct()
45
    {
46
        parent::__construct();
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getId()
53
    {
54
        return $this->id;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getRoles()
61
    {
62
        $roles = $this->roles;
63
64
        $roles[] = static::ROLE_DEFAULT;
65
66
        return array_unique($roles);
67
    }
68
69
    public function isEqualTo(UserInterface $user)
70
    {
71
        $return = true;
72
73
        if ($this->password !== $user->getPassword()) {
74
            $return = false;
75
        }
76
77
        if ($this->username !== $user->getUsername()) {
78
            $return = false;
79
        }
80
81
        return $return;
82
    }
83
}
84