Programmeerimine PHP
/**
* Returns human full name.
* Full name contains firstname, familyname
* and space character between them
*
* @return string human ID code
*/
public function getFullname() {
return $this->firstname.' '.$this->familyname;
}
/**
* Returns human gender.
* Calculates human gender based on
* ID code. If no ID code is set -
* returns null
*
* @return null|string human gender (Male or Female)
*/
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 = '';