1 | <?php |
||
12 | class Calculator extends AbstractCalculator |
||
13 | { |
||
14 | private $subject; |
||
15 | private $omocodiaLevel = 0; |
||
16 | |||
17 | /** |
||
18 | * Array of available vowels. |
||
19 | */ |
||
20 | private $vowels = array('A', 'E', 'I', 'O', 'U'); |
||
21 | |||
22 | /** |
||
23 | * Create a Codice Fiscale instance. |
||
24 | * |
||
25 | * @param Subject $subject The subject that will have the codice fiscale. |
||
26 | * @param array $properties An array with additional properties. |
||
27 | */ |
||
28 | 25 | public function __construct(Subject $subject, $properties = array()) |
|
36 | |||
37 | /** |
||
38 | * Calculate the code fiscale. |
||
39 | * |
||
40 | * @returns string The complete codice fiscale. |
||
41 | */ |
||
42 | 25 | public function calculate() |
|
50 | |||
51 | /** |
||
52 | * Calculate all possibilities for the code fiscale. |
||
53 | * |
||
54 | * @return array The list of all possibilities for the code fiscale. |
||
55 | */ |
||
56 | 5 | public function calculateAllPossibilities() |
|
66 | |||
67 | /** |
||
68 | * Calculate the surname part of the codice fiscale. |
||
69 | * |
||
70 | * @return string The surname part of the codice fiscale. |
||
71 | */ |
||
72 | 25 | private function calculateSurname() |
|
84 | |||
85 | /** |
||
86 | * Calculate the name part of the codice fiscale. |
||
87 | * |
||
88 | * @return string The name part of the codice fiscale. |
||
89 | */ |
||
90 | 25 | private function calculateName() |
|
104 | |||
105 | /** |
||
106 | * Calculate small string for the given parameters (used by name and surname). |
||
107 | * |
||
108 | * @param string $consonants A consonants string. |
||
109 | * @param string $string The small string. |
||
110 | * @return string The calculated result for the small string. |
||
111 | */ |
||
112 | 18 | private function calculateSmallString($consonants, $string) |
|
120 | |||
121 | /** |
||
122 | * Calculate the birth date and the gender. |
||
123 | * |
||
124 | * @returns string The birth date and gender part of the codice fiscale. |
||
125 | */ |
||
126 | 25 | private function calculateBirthDateAndGender() |
|
137 | |||
138 | /** |
||
139 | * Calculate the Belfiore code. |
||
140 | * |
||
141 | * @return string The Belfiore code. |
||
142 | */ |
||
143 | 25 | private function calculateBelfioreCode() |
|
147 | |||
148 | /** |
||
149 | * Calculate the omocodia case (additional translation). |
||
150 | * |
||
151 | * @param $temporaryCodiceFiscale string The first part of the codice fiscale. |
||
152 | * @return string |
||
153 | */ |
||
154 | 25 | private function calculateOmocodia($temporaryCodiceFiscale) |
|
212 | |||
213 | /** |
||
214 | * Replace a section of the omocodia. |
||
215 | * |
||
216 | * @param $divider int The divider. |
||
217 | * @param $temporaryCodiceFiscale string The first part of the codice fiscale on which make the substitutions. |
||
218 | * @param $startingIndex int The starting index. |
||
219 | * @param $endingIndex int The ending index. |
||
220 | * @param $characterIndex int The index to use to make the substitutions on the $temporaryCodiceFiscale. |
||
221 | * @return string The temporary codice fiscale with the substitutions made. |
||
222 | */ |
||
223 | 9 | private function replaceOmocodiaSection( |
|
237 | |||
238 | /** |
||
239 | * @param $string string The string to clean. |
||
240 | * @return string Cleaned string |
||
241 | */ |
||
242 | 25 | private function cleanString($string) |
|
246 | } |
||
247 |