Completed
Push — master ( b33829...886d73 )
by Derek Stephen
06:36
created

Person::getFullName()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 3
nc 4
nop 1
crap 12
1
<?php
2
3
namespace Del\Person\Entity;
4
5
use DateTime;
6
use Del\Entity\Country;
7
use Del\Factory\CountryFactory;
8
use Doctrine\ORM\Mapping as ORM;
9
10
/**
11
 * @ORM\Entity(repositoryClass="\Del\Person\Repository\PersonRepository")
12
 */
13
class Person
14
{
15
    /**
16
     * @ORM\Id
17
     * @ORM\Column(type="integer")
18
     * @ORM\GeneratedValue
19
     */
20
    private $id;
21
22
    /** @ORM\Column(type="string",length=60,nullable=true) */
23
    private $firstname;
24
25
    /** @ORM\Column(type="string",length=60,nullable=true) */
26
    private $middlename;
27
28
    /** @ORM\Column(type="string",length=60,nullable=true) */
29
    private $lastname;
30
31
    /** @ORM\Column(type="string",length=50,nullable=true) */
32
    private $aka;
33
34
    /**
35
     * @ORM\Column(type="date",nullable=true)
36
     * @var DateTime
37
     */
38
    private $dob;
39
40
    /** @ORM\Column(type="string",length=50,nullable=true) */
41
    private $birthplace;
42
43
    /**
44
     * @var string $country
45
     * @ORM\Column(type="string",length=3,nullable=true)
46
     */
47
    private $country;
48
49
    /** @ORM\Column(type="string",length=255,nullable=true) */
50
    private $image;
51
52
    /**
53
     * @return int
54
     */
55 8
    public function getId()
56
    {
57 8
        return $this->id;
58
    }
59
60
    /**
61
     * @param int $id
62
     * @return Person
63
     */
64 5
    public function setId($id)
65
    {
66 5
        $this->id = $id;
67 5
        return $this;
68
    }
69
70
    /**
71
     * @return Country|null
72
     * @throws \Del\CountryException
73
     */
74 3
    public function getCountry(): ?Country
75
    {
76 3
        return $this->country ? CountryFactory::generate($this->country) : null;
77
    }
78
79
    /**
80
     * @param Country $country
81
     * @return Person
82
     */
83 5
    public function setCountry(Country $country)
84
    {
85 5
        $this->country = $country->getIso();
86 5
        return $this;
87
    }
88
89
    /**
90
     * @return string
91
     */
92 4
    public function getFirstname()
93
    {
94 4
        return $this->firstname;
95
    }
96
97
    /**
98
     * @param string $firstname
99
     * @return Person
100
     */
101 6
    public function setFirstname($firstname)
102
    {
103 6
        $this->firstname = $firstname;
104 6
        return $this;
105
    }
106
107
    /**
108
     * @return string
109
     */
110 3
    public function getMiddlename()
111
    {
112 3
        return $this->middlename;
113
    }
114
115
    /**
116
     * @param string $middlename
117
     * @return Person
118
     */
119 5
    public function setMiddlename($middlename)
120
    {
121 5
        $this->middlename = $middlename;
122 5
        return $this;
123
    }
124
125
    /**
126
     * @return string
127
     */
128 3
    public function getLastname()
129
    {
130 3
        return $this->lastname;
131
    }
132
133
    /**
134
     * @param string $lastname
135
     * @return Person
136
     */
137 5
    public function setLastname($lastname)
138
    {
139 5
        $this->lastname = $lastname;
140 5
        return $this;
141
    }
142
143
    /**
144
     * @return string
145
     */
146 4
    public function getAka()
147
    {
148 4
        return $this->aka;
149
    }
150
151
    /**
152
     * @param string $aka
153
     * @return Person
154
     */
155 5
    public function setAka($aka)
156
    {
157 5
        $this->aka = $aka;
158 5
        return $this;
159
    }
160
161
    /**
162
     * @return DateTime
163
     */
164 3
    public function getDob()
165
    {
166 3
        return $this->dob;
167
    }
168
169
    /**
170
     * @param $dob
171
     * @return Person
172
     */
173 5
    public function setDob(DateTime $dob)
174
    {
175 5
        $this->dob = $dob;
176 5
        return $this;
177
    }
178
179
    /**
180
     * @return string
181
     */
182 3
    public function getBirthplace()
183
    {
184 3
        return $this->birthplace;
185
    }
186
187
    /**
188
     * @param string $birthplace
189
     * @return Person
190
     */
191 5
    public function setBirthplace($birthplace)
192
    {
193 5
        $this->birthplace = $birthplace;
194 5
        return $this;
195
    }
196
197
    /**
198
     * @return string
199
     */
200 1
    public function getImage()
201
    {
202 1
        return $this->image;
203
    }
204
205
    /**
206
     * @param string $image
207
     * @return Person
208
     */
209 1
    public function setImage($image)
210
    {
211 1
        $this->image = $image;
212 1
        return $this;
213
    }
214
215
    /**
216
     * @param bool $includeMiddleNames
217
     * @return string
218
     */
219
    public function getFullName($includeMiddleNames = false): string
220
    {
221
        $middleName = $includeMiddleNames && $this->middlename ? ' ' . $this->middlename : '';
222
223
        return $this->firstname . $middleName . ' ' . $this->lastname;
224
    }
225
}
226