Passed
Pull Request — master (#8)
by Derek Stephen
07:57 queued 06:07
created

Person::setAka()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Del\Person\Entity;
6
7
use DateTimeInterface;
8
use Del\Entity\Country;
9
use Del\Factory\CountryFactory;
10
use Doctrine\ORM\Mapping as ORM;
11
use JsonSerializable;
12
13
#[ORM\Entity(repositoryClass: '\Del\Person\Repository\PersonRepository')]
14
class Person implements JsonSerializable
15
{
16
    #[ORM\Id]
17
    #[ORM\Column(type: 'integer')]
18
    #[ORM\GeneratedValue]
19
    private ?int $id = null;
20
21
    #[ORM\Column(type: 'string', length: 60, nullable: true)]
22
    private ?string $firstname = '';
23
24
    #[ORM\Column(type: 'string', length: 60, nullable: true)]
25
    private ?string $middlename = '';
26
27
    #[ORM\Column(type: 'string', length: 60, nullable: true)]
28
    private ?string $lastname = '';
29
30
    #[ORM\Column(type: 'string', length: 50, nullable: true)]
31
    private ?string $aka = '';
32
33
    #[ORM\Column(type: 'date', nullable: true)]
34
    private ?DateTimeInterface $dob = null;
35
36
    #[ORM\Column(type: 'string', length: 50, nullable: true)]
37
    private ?string $birthplace = '';
38
39
    #[ORM\Column(type: 'string', length: 3, nullable: true)]
40
    private ?string $country = '';
41
42
    #[ORM\Column(type: 'string', length: 255, nullable: true)]
43
    private ?string $image = '';
44
45
    #[ORM\Column(type: 'string', length: 255, nullable: true)]
46
    private ?string $backgroundImage = '';
47
48 9
    public function getId(): ?int
49
    {
50 9
        return $this->id;
51
    }
52
53 9
    public function setId(int $id): void
54
    {
55 9
        $this->id = $id;
56
    }
57
58 3
    public function getCountry(): ?Country
59
    {
60 3
        return $this->country ? CountryFactory::generate($this->country) : null;
61
    }
62
63 5
    public function setCountry(Country $country): void
64
    {
65 5
        $this->country = $country->getIso();
66
    }
67
68 5
    public function getFirstname(): ?string
69
    {
70 5
        return $this->firstname;
71
    }
72
73 7
    public function setFirstname(string $firstname): void
74
    {
75 7
        $this->firstname = $firstname;
76
    }
77
78 4
    public function getMiddlename(): ?string
79
    {
80 4
        return $this->middlename;
81
    }
82
83 6
    public function setMiddlename(string $middlename): void
84
    {
85 6
        $this->middlename = $middlename;
86
    }
87
88 4
    public function getLastname(): ?string
89
    {
90 4
        return $this->lastname;
91
    }
92
93 6
    public function setLastname(string $lastname): void
94
    {
95 6
        $this->lastname = $lastname;
96
    }
97
98 5
    public function getAka(): ?string
99
    {
100 5
        return $this->aka;
101
    }
102
103 5
    public function setAka(string $aka): void
104
    {
105 5
        $this->aka = $aka;
106
    }
107
108 4
    public function getDob(): ?DateTimeInterface
109
    {
110 4
        return $this->dob;
111
    }
112
113 5
    public function setDob(DateTimeInterface $dob): void
114
    {
115 5
        $this->dob = $dob;
116
    }
117
118 4
    public function getBirthplace(): ?string
119
    {
120 4
        return $this->birthplace;
121
    }
122
123 5
    public function setBirthplace(string $birthplace): void
124
    {
125 5
        $this->birthplace = $birthplace;
126
    }
127
128 3
    public function getImage(): ?string
129
    {
130 3
        return $this->image;
131
    }
132
133 1
    public function setImage(string $image): void
134
    {
135 1
        $this->image = $image;
136
    }
137
138 2
    public function getBackgroundImage(): ?string
139
    {
140 2
        return $this->backgroundImage;
141
    }
142
143 1
    public function setBackgroundImage(string $backgroundImage): void
144
    {
145 1
        $this->backgroundImage = $backgroundImage;
146
    }
147
148 1
    public function getFullName($includeMiddleNames = false): string
149
    {
150 1
        $middleName = $includeMiddleNames && $this->middlename ? ' ' . $this->middlename : '';
151
152 1
        return $this->firstname . $middleName . ' ' . $this->lastname;
153
    }
154
155 1
    public function toArray(): array
156
    {
157 1
        return [
158 1
            'id' => $this->getId(),
159 1
            'firstname' => $this->getFirstname(),
160 1
            'middlename' => $this->getMiddlename(),
161 1
            'lastname' => $this->getLastname(),
162 1
            'aka' => $this->getAka(),
163 1
            'dob' => $this->getDob(),
164 1
            'birthplace' => $this->getBirthplace(),
165 1
            'country' => $this->country ? $this->getCountry()->getIso() : null,
166 1
            'image' => $this->getImage(),
167 1
            'backgrundImage' => $this->getImage(),
168 1
        ];
169
    }
170
171 1
    public function jsonSerialize(): array
172
    {
173 1
        return $this->toArray();
174
    }
175
}
176