Programmeerimine PHP
*/
public function getGender() {
if (is_null ($this->idCode)) return null;
$genderNumber = substr ($this->idCode, 0, 1);
if ($genderNumber % 2 == 0) {
return 'Female';
} else {
return 'Male';
}
}
/**
* Returns human date of birth.
* Calculates human birthday based on
* ID code. If no ID code is set -
* returns null. Date format: DD.MM.YYYY
*
* @return null|string human date of birth
*/
public function getBirthday() {
if (is_null ($this->idCode)) return null;
$genderNumber = substr ($this->idCode, 0, 1);
$year = '';
switch ($genderNumber) {
case '1':
case '2':
$year = '18';
break;
case '3':
case '4':
$year = '19';
break;
case '5':
case '6':
$year = '20';
break;
}
$year .= substr($this->idCode, 1, 2);