@@ -40,92 +40,92 @@ discard block |
||
| 40 | 40 | * Array of all avaialable odd characters. |
| 41 | 41 | */ |
| 42 | 42 | private $odd = array( |
| 43 | - '0' => 1, |
|
| 44 | - '1' => 0, |
|
| 45 | - '2' => 5, |
|
| 46 | - '3' => 7, |
|
| 47 | - '4' => 9, |
|
| 48 | - '5' => 13, |
|
| 49 | - '6' => 15, |
|
| 50 | - '7' => 17, |
|
| 51 | - '8' => 19, |
|
| 52 | - '9' => 21, |
|
| 53 | - 'A' => 1, |
|
| 54 | - 'B' => 0, |
|
| 55 | - 'C' => 5, |
|
| 56 | - 'D' => 7, |
|
| 57 | - 'E' => 9, |
|
| 58 | - 'F' => 13, |
|
| 59 | - 'G' => 15, |
|
| 60 | - 'H' => 17, |
|
| 61 | - 'I' => 19, |
|
| 62 | - 'J' => 21, |
|
| 63 | - 'K' => 2, |
|
| 64 | - 'L' => 4, |
|
| 65 | - 'M' => 18, |
|
| 66 | - 'N' => 20, |
|
| 67 | - 'O' => 11, |
|
| 68 | - 'P' => 3, |
|
| 69 | - 'Q' => 6, |
|
| 70 | - 'R' => 8, |
|
| 71 | - 'S' => 12, |
|
| 72 | - 'T' => 14, |
|
| 73 | - 'U' => 16, |
|
| 74 | - 'V' => 10, |
|
| 75 | - 'W' => 22, |
|
| 76 | - 'X' => 25, |
|
| 77 | - 'Y' => 24, |
|
| 78 | - 'Z' => 23 |
|
| 79 | - ); |
|
| 43 | + '0' => 1, |
|
| 44 | + '1' => 0, |
|
| 45 | + '2' => 5, |
|
| 46 | + '3' => 7, |
|
| 47 | + '4' => 9, |
|
| 48 | + '5' => 13, |
|
| 49 | + '6' => 15, |
|
| 50 | + '7' => 17, |
|
| 51 | + '8' => 19, |
|
| 52 | + '9' => 21, |
|
| 53 | + 'A' => 1, |
|
| 54 | + 'B' => 0, |
|
| 55 | + 'C' => 5, |
|
| 56 | + 'D' => 7, |
|
| 57 | + 'E' => 9, |
|
| 58 | + 'F' => 13, |
|
| 59 | + 'G' => 15, |
|
| 60 | + 'H' => 17, |
|
| 61 | + 'I' => 19, |
|
| 62 | + 'J' => 21, |
|
| 63 | + 'K' => 2, |
|
| 64 | + 'L' => 4, |
|
| 65 | + 'M' => 18, |
|
| 66 | + 'N' => 20, |
|
| 67 | + 'O' => 11, |
|
| 68 | + 'P' => 3, |
|
| 69 | + 'Q' => 6, |
|
| 70 | + 'R' => 8, |
|
| 71 | + 'S' => 12, |
|
| 72 | + 'T' => 14, |
|
| 73 | + 'U' => 16, |
|
| 74 | + 'V' => 10, |
|
| 75 | + 'W' => 22, |
|
| 76 | + 'X' => 25, |
|
| 77 | + 'Y' => 24, |
|
| 78 | + 'Z' => 23 |
|
| 79 | + ); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Array of all avaialable even characters. |
| 83 | 83 | */ |
| 84 | - private $even = array( |
|
| 85 | - '0' => 0, |
|
| 86 | - '1' => 1, |
|
| 87 | - '2' => 2, |
|
| 88 | - '3' => 3, |
|
| 89 | - '4' => 4, |
|
| 90 | - '5' => 5, |
|
| 91 | - '6' => 6, |
|
| 92 | - '7' => 7, |
|
| 93 | - '8' => 8, |
|
| 94 | - '9' => 9, |
|
| 95 | - 'A' => 0, |
|
| 96 | - 'B' => 1, |
|
| 97 | - 'C' => 2, |
|
| 98 | - 'D' => 3, |
|
| 99 | - 'E' => 4, |
|
| 100 | - 'F' => 5, |
|
| 101 | - 'G' => 6, |
|
| 102 | - 'H' => 7, |
|
| 103 | - 'I' => 8, |
|
| 104 | - 'J' => 9, |
|
| 105 | - 'K' => 10, |
|
| 106 | - 'L' => 11, |
|
| 107 | - 'M' => 12, |
|
| 108 | - 'N' => 13, |
|
| 109 | - 'O' => 14, |
|
| 110 | - 'P' => 15, |
|
| 111 | - 'Q' => 16, |
|
| 112 | - 'R' => 17, |
|
| 113 | - 'S' => 18, |
|
| 114 | - 'T' => 19, |
|
| 115 | - 'U' => 20, |
|
| 116 | - 'V' => 21, |
|
| 117 | - 'W' => 22, |
|
| 118 | - 'X' => 23, |
|
| 119 | - 'Y' => 24, |
|
| 120 | - 'Z' => 25 |
|
| 121 | - ); |
|
| 84 | + private $even = array( |
|
| 85 | + '0' => 0, |
|
| 86 | + '1' => 1, |
|
| 87 | + '2' => 2, |
|
| 88 | + '3' => 3, |
|
| 89 | + '4' => 4, |
|
| 90 | + '5' => 5, |
|
| 91 | + '6' => 6, |
|
| 92 | + '7' => 7, |
|
| 93 | + '8' => 8, |
|
| 94 | + '9' => 9, |
|
| 95 | + 'A' => 0, |
|
| 96 | + 'B' => 1, |
|
| 97 | + 'C' => 2, |
|
| 98 | + 'D' => 3, |
|
| 99 | + 'E' => 4, |
|
| 100 | + 'F' => 5, |
|
| 101 | + 'G' => 6, |
|
| 102 | + 'H' => 7, |
|
| 103 | + 'I' => 8, |
|
| 104 | + 'J' => 9, |
|
| 105 | + 'K' => 10, |
|
| 106 | + 'L' => 11, |
|
| 107 | + 'M' => 12, |
|
| 108 | + 'N' => 13, |
|
| 109 | + 'O' => 14, |
|
| 110 | + 'P' => 15, |
|
| 111 | + 'Q' => 16, |
|
| 112 | + 'R' => 17, |
|
| 113 | + 'S' => 18, |
|
| 114 | + 'T' => 19, |
|
| 115 | + 'U' => 20, |
|
| 116 | + 'V' => 21, |
|
| 117 | + 'W' => 22, |
|
| 118 | + 'X' => 23, |
|
| 119 | + 'Y' => 24, |
|
| 120 | + 'Z' => 25 |
|
| 121 | + ); |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * Array of all avaialable omocodia characters. |
| 125 | 125 | */ |
| 126 | - private $omocodiaCodes = array( |
|
| 127 | - '0' => 'L', |
|
| 128 | - '1' => 'M', |
|
| 126 | + private $omocodiaCodes = array( |
|
| 127 | + '0' => 'L', |
|
| 128 | + '1' => 'M', |
|
| 129 | 129 | '2' => 'N', |
| 130 | 130 | '3' => 'P', |
| 131 | 131 | '4' => 'Q', |
@@ -134,20 +134,20 @@ discard block |
||
| 134 | 134 | '7' => 'T', |
| 135 | 135 | '8' => 'U', |
| 136 | 136 | '9' => 'V' |
| 137 | - ); |
|
| 137 | + ); |
|
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Create a Codice Fiscale instance. |
|
| 141 | - * @param Subject $subject The subject that will have the codice fiscale. |
|
| 139 | + /** |
|
| 140 | + * Create a Codice Fiscale instance. |
|
| 141 | + * @param Subject $subject The subject that will have the codice fiscale. |
|
| 142 | 142 | * @param $properties An array with additional properties. |
| 143 | - */ |
|
| 144 | - public function __construct(Subject $subject, $properties = array()){ |
|
| 143 | + */ |
|
| 144 | + public function __construct(Subject $subject, $properties = array()){ |
|
| 145 | 145 | $this->subject = $subject; |
| 146 | 146 | |
| 147 | 147 | if (array_key_exists('omocodiaLevel', $properties)) { |
| 148 | 148 | $this->omocodiaLevel = $properties['omocodiaLevel']; |
| 149 | 149 | } |
| 150 | - } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * Calculate the code fiscale. |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function calculate(){ |
| 157 | 157 | $temporaryCodiceFiscale = $this->calculateSurname() . $this->calculateName() . |
| 158 | - $this->calculateBirthDateAndGender() . $this->calculateBelfioreCode(); |
|
| 158 | + $this->calculateBirthDateAndGender() . $this->calculateBelfioreCode(); |
|
| 159 | 159 | $temporaryCodiceFiscale = $this->calculateOmocodia($temporaryCodiceFiscale); |
| 160 | 160 | return $temporaryCodiceFiscale . $this->calculateCheckDigit($temporaryCodiceFiscale); |
| 161 | 161 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $result = substr($consonants, 0, 3); |
| 185 | 185 | } else { |
| 186 | 186 | $vowels = str_replace(str_split($consonants), '', $this->subject->getSurname()); |
| 187 | - $result = substr($consonants . $vowels . 'XXX', 0, 3); |
|
| 187 | + $result = substr($consonants . $vowels . 'XXX', 0, 3); |
|
| 188 | 188 | } |
| 189 | 189 | return $result; |
| 190 | 190 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $result = join($consonants); |
| 202 | 202 | } else{ |
| 203 | 203 | $vowels = str_replace(str_split($consonants), '', $this->subject->getName()); |
| 204 | - $result = substr($consonants . $vowels . 'XXX', 0, 3); |
|
| 204 | + $result = substr($consonants . $vowels . 'XXX', 0, 3); |
|
| 205 | 205 | } |
| 206 | 206 | return $result; |
| 207 | 207 | } |
@@ -250,10 +250,10 @@ discard block |
||
| 250 | 250 | private function calculateSumByDictionary($temporaryCodiceFiscale, $dictionaryArray, $i){ |
| 251 | 251 | $sum = 0; |
| 252 | 252 | for (; $i < 15; $i = $i + 2) |
| 253 | - { |
|
| 254 | - $k = $temporaryCodiceFiscale{$i}; |
|
| 255 | - $sum = $sum + $dictionaryArray[$k]; |
|
| 256 | - } |
|
| 253 | + { |
|
| 254 | + $k = $temporaryCodiceFiscale{$i}; |
|
| 255 | + $sum = $sum + $dictionaryArray[$k]; |
|
| 256 | + } |
|
| 257 | 257 | return $sum; |
| 258 | 258 | } |
| 259 | 259 | |