Completed
Pull Request — master (#39)
by Davide
01:20
created

Subject::getBelfioreCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace CodiceFiscale;
4
5
use DateTime;
6
use DateTimeInterface;
7
use Exception;
8
9
/**
10
 * The subject of the codice fiscale.
11
 *
12
 * @author davidepastore
13
 */
14
class Subject
15
{
16
    private $name;
17
    private $surname;
18
    private $birthDate;
19
    private $gender;
20
    private $belfioreCode;
21
22
    /**
23
     * Create a Codice Fiscale instance.
24
     *
25
     * @param array $properties An array with all the properties.
26
     *                          Supported keys are:
27
     *                          - name: the name;
28
     *                          - surname: the surname;
29
     *                          - birthDate: the birth date;
30
     *                          - gender: the gender;
31
     *                          - belfioreCode: the Belfiore code.
32
     * @throws Exception
33
     */
34 155
    public function __construct($properties)
35
    {
36
        //Set properties
37 155
        if (array_key_exists('name', $properties)) {
38 12
            $this->name = $properties['name'];
39
        }
40
41 155
        if (array_key_exists('surname', $properties)) {
42 12
            $this->surname = $properties['surname'];
43
        }
44
45 155
        if (array_key_exists('birthDate', $properties)) {
46 155
            $this->setBirthDate($properties['birthDate']);
47
        }
48
49 155
        if (array_key_exists('gender', $properties)) {
50 155
            $this->gender = $properties['gender'];
51
        }
52
53 155
        if (array_key_exists('belfioreCode', $properties)) {
54 155
            $this->belfioreCode = $properties['belfioreCode'];
55
        }
56 155
    }
57
58
    /**
59
     * Get the name.
60
     *
61
     * @return string The name.
62
     */
63 170
    public function getName()
64
    {
65 170
        return $this->name;
66
    }
67
68
    /**
69
     * Set the name.
70
     */
71 1
    public function setName($name)
72
    {
73 1
        $this->name = $name;
74 1
    }
75
76
    /**
77
     * Get the name.
78
     *
79
     * @return string The name.
80
     */
81 170
    public function getSurname()
82
    {
83 170
        return $this->surname;
84
    }
85
86
    /**
87
     * Set the surname.
88
     *
89
     * @param string $surname
90
     */
91 1
    public function setSurname($surname)
92
    {
93 1
        $this->surname = $surname;
94 1
    }
95
96
    /**
97
     * Get the birthDate.
98
     *
99
     * @return DateTime The birthDate.
100
     */
101 172
    public function getBirthDate()
102
    {
103 172
        return $this->birthDate;
104
    }
105
106
    /**
107
     * Set the birthDate.
108
     * @param mixed $birthDate
109
     * @throws Exception
110
     */
111 155
    public function setBirthDate($birthDate)
112
    {
113 155
        if (!$birthDate instanceof DateTimeInterface) {
114 12
            $birthDate = new DateTime($birthDate);
115
        }
116
117 155
        $this->birthDate = $birthDate;
118 155
    }
119
120
    /**
121
     * Get the gender.
122
     *
123
     * @return string The gender.
124
     */
125 170
    public function getGender()
126
    {
127 170
        return $this->gender;
128
    }
129
130
    /**
131
     * Set the gender.
132
     *
133
     * @param string $gender
134
     */
135 1
    public function setGender($gender)
136
    {
137 1
        $this->gender = $gender;
138 1
    }
139
140
    /**
141
     * Get the belfioreCode.
142
     *
143
     * @return string The belfioreCode.
144
     */
145 170
    public function getBelfioreCode()
146
    {
147 170
        return $this->belfioreCode;
148
    }
149
150
    /**
151
     * Set the belfioreCode.
152
     * @param string $belfioreCode
153
     */
154 1
    public function setBelfioreCode($belfioreCode)
155
    {
156 1
        $this->belfioreCode = $belfioreCode;
157 1
    }
158
}
159