User   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Test Coverage

Coverage 64.71%

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 110
ccs 11
cts 17
cp 0.6471
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getEmail() 0 3 1
A getName() 0 3 1
A getLastName() 0 3 1
A __construct() 0 5 1
A getFirstName() 0 3 1
A isACustomer() 0 3 1
A __toString() 0 3 1
1
<?php
2
3
namespace Matks\Bundle\CustomerSupportBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
7
use Symfony\Component\Validator\Constraints as Assert;
8
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
9
use LogicException;
10
11
use Matks\Bundle\CustomerSupportBundle\Model\UserInterface;
12
13
/**
14
 * User entity
15
 *
16
 * @ORM\Entity(repositoryClass="Matks\Bundle\CustomerSupportBundle\Repository\UserRepository")
17
 * @ORM\InheritanceType("SINGLE_TABLE")
18
 * @ORM\DiscriminatorColumn(name="discr", type="string")
19
 * @ORM\Table(name="users", indexes={@ORM\Index(name="user_email_idx", columns={"email"})})
20
 * @UniqueEntity(fields="email", message="this email already exists")
21
 * @ORM\HasLifecycleCallbacks
22
 *
23
 * @author Mathieu Ferment <[email protected]>
24
 */
25
class User implements UserInterface
26
{
27
    use ORMBehaviors\Timestampable\Timestampable;
28
29
    /**
30
     * @var int
31
     *
32
     * @ORM\Id
33
     * @ORM\Column(type="integer")
34
     * @ORM\GeneratedValue(strategy="AUTO")
35
     */
36
    private $id;
0 ignored issues
show
introduced by
The private property $id is not used, and could be removed.
Loading history...
37
38
    /**
39
     * @var string
40
     *
41
     * @ORM\Column(type="string", length=255)
42
     */
43
    private $email;
44
45
    /**
46
     * @var string
47
     *
48
     * @ORM\Column(type="string", length=255, name="first_name")
49
     * @Assert\NotBlank()
50
     */
51
    private $firstName;
52
53
    /**
54
     * @var string
55
     *
56
     * @ORM\Column(type="string", length=255, name="last_name")
57
     * @Assert\NotBlank()
58
     */
59
    private $lastName;
60
61
    /**
62
     * @var Name
0 ignored issues
show
Bug introduced by
The type Matks\Bundle\CustomerSupportBundle\Entity\Name was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
63
     */
64
    private $name;
0 ignored issues
show
introduced by
The private property $name is not used, and could be removed.
Loading history...
65
66
    /**
67
     * Constructor
68
     *
69
     * @param string $firstName
70
     * @param string $lastName
71
     * @param string $email
72
     */
73 6
    public function __construct($firstName, $lastName, $email)
74
    {
75 6
        $this->firstName = $firstName;
76 6
        $this->lastName  = $lastName;
77 6
        $this->email     = $email;
78 6
    }
79
80
    /**
81
     * @return string
82
     */
83 1
    public function __toString()
84
    {
85 1
        return $this->email;
86
    }
87
88
    /**
89
     * Get full name
90
     *
91
     * @return string
92
     */
93 1
    public function getName()
94
    {
95 1
        return $this->firstName . ' ' . $this->lastName;
96
    }
97
98
    /**
99
     * Get first name
100
     *
101
     * @return string
102
     */
103
    public function getFirstName()
104
    {
105
        return $this->firstName;
106
    }
107
108
    /**
109
     * Get last name
110
     *
111
     * @return string
112
     */
113
    public function getLastName()
114
    {
115
        return $this->lastName;
116
    }
117
118
    /**
119
     * Get email
120
     *
121
     * @return string
122
     */
123
    public function getEmail()
124
    {
125
        return $this->email;
126
    }
127
128
    /**
129
     * @return bool
130
     * @throws Exception: should be called on children classes
131
     */
132 1
    public function isACustomer()
133
    {
134 1
        throw new LogicException("This function should never be called on a user");
135
    }
136
}
137