Completed
Push — master ( ec0306...353f5c )
by Davide
8s
created

Subject::setSurname()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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