diff --git a/src/CodiceFiscale/Checker.php b/src/CodiceFiscale/Checker.php index fc52acb..6eea99d 100644 --- a/src/CodiceFiscale/Checker.php +++ b/src/CodiceFiscale/Checker.php @@ -10,7 +10,7 @@ class Checker { // fiscal's code regex - const REGEX_CODICEFISCALE = '/^[a-z]{6}[0-9]{2}[a-z][0-9]{2}[a-z][0-9]{3}[a-z]$/i'; + const REGEX_CODICEFISCALE = '/^[a-z]{6}[0-9lmnpqrstuvLMNPQRSTUV]{2}[a-z][0-9lmnpqrstuvLMNPQRSTUV]{2}[a-z][0-9lmnpqrstuvLMNPQRSTUV]{3}[a-z]$/i'; // women char const CHR_WOMEN = 'F'; @@ -30,12 +30,24 @@ class Checker */ private $sex = null; + /** + * Real Country Birth + * @var integer + */ + private $realCountryBirth = null; + /** * Country Birth * @var integer */ private $countryBirth = null; + /** + * Day Birth + * @var integer + */ + private $realDayBirth = null; + /** * Day Birth * @var integer @@ -48,6 +60,12 @@ class Checker */ private $monthBirth = null; + /** + * Year Birth + * @var integer + */ + private $realYearBirth = null; + /** * Year Birth * @var integer @@ -143,6 +161,17 @@ public function getCountryBirth() } + + /** + * Getter CountryBirth + * @return integer + */ + public function getRealCountryBirth() + { + return $this->realCountryBirth; + } + + /** * Getter YearBirth * @return integer @@ -153,6 +182,18 @@ public function getYearBirth() } + + /** + * Getter YearBirth + * @return integer + */ + public function getRealYearBirth() + { + return $this->realYearBirth; + } + + + /** * Getter MonthBirth * @return integer @@ -173,6 +214,16 @@ public function getDayBirth() } + /** + * Getter DayBirth + * @return integer + */ + public function getRealDayBirth() + { + return $this->realDayBirth; + } + + /** * Check Codice Fiscale * @param string $codiceFiscale @@ -223,16 +274,18 @@ public function isFormallyCorrect($codiceFiscale) if (!($this->listCtrlCode[($pari + $dispari) % 26] === $cFCharList[15])) { $this->raiseException(4); } - + $tempCFCharList = $cFCharList; // replace "omocodie" for ($i = 0; $i < count($this->listSostOmocodia); $i++) { if (!is_numeric($cFCharList[$this->listSostOmocodia[$i]])) { - $CFCharList[$this->listSostOmocodia[$i]] = $this->listDecOmocodia[$cFCharList[$this->listSostOmocodia[$i]]]; + $cFCharList[$this->listSostOmocodia[$i]] = $this->listDecOmocodia[$cFCharList[$this->listSostOmocodia[$i]]]; } } - + $tempCodiceFiscaleAdattato = implode($tempCFCharList); $codiceFiscaleAdattato = implode($cFCharList); - + $this->realCountryBirth = substr($tempCodiceFiscaleAdattato, 11, 4); + $this->realYearBirth = substr($tempCodiceFiscaleAdattato, 6, 2); + $this->realDayBirth = substr($tempCodiceFiscaleAdattato, 9, 2); // get fiscal code data $this->sex = ((int)(substr($codiceFiscaleAdattato, 9, 2) > 40) ? self::CHR_WOMEN : self::CHR_MALE); $this->countryBirth = substr($codiceFiscaleAdattato, 11, 4);