@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param Subject $subject The subject that will have the codice fiscale. |
141 | 141 | * @param $properties An array with additional properties. |
142 | 142 | */ |
143 | - public function __construct(Subject $subject, $properties = array()){ |
|
143 | + public function __construct(Subject $subject, $properties = array()) { |
|
144 | 144 | $this->subject = $subject; |
145 | 145 | |
146 | 146 | if (array_key_exists('omocodiaLevel', $properties)) { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * Calculate the code fiscale. |
153 | 153 | * @returns Returns the complete codice fiscale. |
154 | 154 | */ |
155 | - public function calculate(){ |
|
155 | + public function calculate() { |
|
156 | 156 | $temporaryCodiceFiscale = $this->calculateSurname() . $this->calculateName() . |
157 | 157 | $this->calculateBirthDateAndGender() . $this->calculateBelfioreCode(); |
158 | 158 | $temporaryCodiceFiscale = $this->calculateOmocodia($temporaryCodiceFiscale); |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * Calculate all possibilities for the code fiscale. |
164 | 164 | * @returns Returns the complete codice fiscale. |
165 | 165 | */ |
166 | - public function calculateAllPossibilities(){ |
|
166 | + public function calculateAllPossibilities() { |
|
167 | 167 | $allPossibilities = array(); |
168 | - for($i = 0; $i < 8; $i++){ |
|
168 | + for ($i = 0; $i < 8; $i++) { |
|
169 | 169 | $this->omocodiaLevel = $i; |
170 | 170 | $allPossibilities[] = $this->calculate(); |
171 | 171 | } |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | * Calculate the surname part of the codice fiscale. |
178 | 178 | * @returns Returns the surname part of the codice fiscale. |
179 | 179 | */ |
180 | - private function calculateSurname(){ |
|
180 | + private function calculateSurname() { |
|
181 | 181 | $consonants = str_replace($this->vowels, '', $this->subject->getSurname()); |
182 | - if(strlen($consonants) > 2){ |
|
182 | + if (strlen($consonants) > 2) { |
|
183 | 183 | $result = substr($consonants, 0, 3); |
184 | 184 | } else { |
185 | 185 | $vowels = str_replace(str_split($consonants), '', $this->subject->getSurname()); |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | * Calculate the name part of the codice fiscale. |
193 | 193 | * @returns Returns the name part of the codice fiscale. |
194 | 194 | */ |
195 | - private function calculateName(){ |
|
195 | + private function calculateName() { |
|
196 | 196 | $consonants = str_replace($this->vowels, '', $this->subject->getName()); |
197 | - if(strlen($consonants) > 3){ |
|
197 | + if (strlen($consonants) > 3) { |
|
198 | 198 | $result = $consonants[0] . $consonants[2] . $consonants[3]; |
199 | - } else if(strlen($consonants) == 3){ |
|
199 | + } else if (strlen($consonants) == 3) { |
|
200 | 200 | $result = join($consonants); |
201 | - } else{ |
|
201 | + } else { |
|
202 | 202 | $vowels = str_replace(str_split($consonants), '', $this->subject->getName()); |
203 | 203 | $result = substr($consonants . $vowels . 'XXX', 0, 3); |
204 | 204 | } |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * Calculate the birth date and the gender. |
210 | 210 | * @returns Returns the birth date and gender part of the codice fiscale. |
211 | 211 | */ |
212 | - private function calculateBirthDateAndGender(){ |
|
212 | + private function calculateBirthDateAndGender() { |
|
213 | 213 | $year = $this->subject->getBirthDate()->format('y'); |
214 | 214 | $month = $this->months[$this->subject->getBirthDate()->format('n')]; |
215 | 215 | $day = $this->subject->getBirthDate()->format('d'); |
216 | - if($this->subject->getGender() == "F"){ |
|
216 | + if ($this->subject->getGender() == "F") { |
|
217 | 217 | $day += 40; |
218 | 218 | } |
219 | 219 | return $year . $month . $day; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * Calculate the Belfiore code. |
224 | 224 | * @returns Returns the Belfiore code. |
225 | 225 | */ |
226 | - private function calculateBelfioreCode(){ |
|
226 | + private function calculateBelfioreCode() { |
|
227 | 227 | return $this->subject->getBelfioreCode(); |
228 | 228 | } |
229 | 229 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @param $temporaryCodiceFiscale The first part of the codice fiscale. |
233 | 233 | * @returns Returns the check digit part of the codice fiscale. |
234 | 234 | */ |
235 | - private function calculateCheckDigit($temporaryCodiceFiscale){ |
|
235 | + private function calculateCheckDigit($temporaryCodiceFiscale) { |
|
236 | 236 | $sumEven = 0; |
237 | 237 | $sumOdd = 0; |
238 | 238 | for ($i = 0; $i < 15; $i = $i + 2) |
@@ -255,12 +255,12 @@ discard block |
||
255 | 255 | * @param $temporaryCodiceFiscale The first part of the codice fiscale. |
256 | 256 | * @returns Returns the new codice fiscale. |
257 | 257 | */ |
258 | - private function calculateOmocodia($temporaryCodiceFiscale){ |
|
259 | - if($this->omocodiaLevel > 0){ |
|
258 | + private function calculateOmocodia($temporaryCodiceFiscale) { |
|
259 | + if ($this->omocodiaLevel > 0) { |
|
260 | 260 | $omocodiaLevelApplied = 0; |
261 | - for($i = strlen($temporaryCodiceFiscale) - 1; $i > 0; $i--){ |
|
261 | + for ($i = strlen($temporaryCodiceFiscale) - 1; $i > 0; $i--) { |
|
262 | 262 | $k = $temporaryCodiceFiscale{$i}; |
263 | - if($omocodiaLevelApplied < $this->omocodiaLevel && is_numeric($k)){ |
|
263 | + if ($omocodiaLevelApplied < $this->omocodiaLevel && is_numeric($k)) { |
|
264 | 264 | $newChar = $this->omocodiaCodes[$k]; |
265 | 265 | $temporaryCodiceFiscale{$i} = $newChar; |
266 | 266 | $omocodiaLevelApplied++; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param Subject $subject The subject. |
24 | 24 | * @param $properties Array of additional properties. |
25 | 25 | */ |
26 | - public function __construct(Subject $subject, $properties = array()){ |
|
26 | + public function __construct(Subject $subject, $properties = array()) { |
|
27 | 27 | $this->subject = $subject; |
28 | 28 | |
29 | 29 | if (array_key_exists('codiceFiscaleToCheck', $properties)) { |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | * Check if the given data is ok for the given codice fiscale. |
40 | 40 | * @returns Returns true if the codice fiscale is ok, false otherwise. |
41 | 41 | */ |
42 | - public function check(){ |
|
42 | + public function check() { |
|
43 | 43 | $calculator = new Calculator($this->subject, array( |
44 | 44 | "omocodiaLevel" => $this->omocodiaLevel |
45 | 45 | )); |
46 | - if($this->omocodiaLevel == Checker::ALL_OMOCODIA_LEVELS){ |
|
46 | + if ($this->omocodiaLevel == Checker::ALL_OMOCODIA_LEVELS) { |
|
47 | 47 | $values = $calculator->calculateAllPossibilities(); |
48 | 48 | } else { |
49 | 49 | $values = array($calculator->calculate()); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * - gender: the gender; |
26 | 26 | * - belfioreCode: the Belfiore code. |
27 | 27 | */ |
28 | - public function __construct($properties){ |
|
28 | + public function __construct($properties) { |
|
29 | 29 | //Set properties |
30 | 30 | if (array_key_exists('name', $properties)) { |
31 | 31 | $this->name = strtoupper($properties['name']); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | if (array_key_exists('birthDate', $properties)) { |
39 | - if(!$properties['birthDate'] instanceof \DateTime){ |
|
39 | + if (!$properties['birthDate'] instanceof \DateTime) { |
|
40 | 40 | $properties['birthDate'] = new \DateTime($properties['birthDate']); |
41 | 41 | } |
42 | 42 | $this->birthDate = $properties['birthDate']; |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | * Get the name. |
56 | 56 | * @return Returns the name. |
57 | 57 | */ |
58 | - public function getName(){ |
|
58 | + public function getName() { |
|
59 | 59 | return $this->name; |
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Set the name. |
64 | 64 | */ |
65 | - public function setName($name){ |
|
65 | + public function setName($name) { |
|
66 | 66 | $this->name = $name; |
67 | 67 | } |
68 | 68 | |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * Get the name. |
71 | 71 | * @return Returns the name. |
72 | 72 | */ |
73 | - public function getSurname(){ |
|
73 | + public function getSurname() { |
|
74 | 74 | return $this->surname; |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Set the surname. |
79 | 79 | */ |
80 | - public function setSurname($surname){ |
|
80 | + public function setSurname($surname) { |
|
81 | 81 | $this->surname = $surname; |
82 | 82 | } |
83 | 83 | |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | * Get the birthDate. |
86 | 86 | * @return Returns the birthDate. |
87 | 87 | */ |
88 | - public function getBirthDate(){ |
|
88 | + public function getBirthDate() { |
|
89 | 89 | return $this->birthDate; |
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Set the birthDate. |
94 | 94 | */ |
95 | - public function setBirthDate($birthDate){ |
|
95 | + public function setBirthDate($birthDate) { |
|
96 | 96 | $this->birthDate = $birthDate; |
97 | 97 | } |
98 | 98 | |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | * Get the gender. |
101 | 101 | * @return Returns the gender. |
102 | 102 | */ |
103 | - public function getGender(){ |
|
103 | + public function getGender() { |
|
104 | 104 | return $this->gender; |
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Set the gender. |
109 | 109 | */ |
110 | - public function setGender($gender){ |
|
110 | + public function setGender($gender) { |
|
111 | 111 | $this->gender = $gender; |
112 | 112 | } |
113 | 113 | |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * Get the belfioreCode. |
116 | 116 | * @return Returns the belfioreCode. |
117 | 117 | */ |
118 | - public function getBelfioreCode(){ |
|
118 | + public function getBelfioreCode() { |
|
119 | 119 | return $this->belfioreCode; |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Set the belfioreCode. |
124 | 124 | */ |
125 | - public function setBelfioreCode($belfioreCode){ |
|
125 | + public function setBelfioreCode($belfioreCode) { |
|
126 | 126 | $this->belfioreCode = $belfioreCode; |
127 | 127 | } |
128 | 128 | } |