lastName() . 'son'; } /** * Randomly return a icelandic last name for man. * * @return string */ public function lastNameFemale() { return $this->lastName() . 'dóttir'; } /** * Randomly return a icelandic Kennitala (Social Security number) format. * * @see http://en.wikipedia.org/wiki/Kennitala * * @return string */ public static function ssn() { // random birth date $birthdate = DateTime::dateTimeThisCentury(); // last four buffer $lastFour = null; // security variable reference $ref = '32765432'; // valid flag $valid = false; while (!$valid) { // make two random numbers $rand = static::randomDigit() . static::randomDigit(); // 8 char string with birth date and two random numbers $tmp = $birthdate->format('dmy') . $rand; // loop through temp string for ($i = 7, $sum = 0; $i >= 0; --$i) { // calculate security variable $sum += ($tmp[$i] * $ref[$i]); } // subtract 11 if not 11 $chk = ($sum % 11 === 0) ? 0 : (11 - ($sum % 11)); if ($chk < 10) { $lastFour = $rand . $chk . substr($birthdate->format('Y'), 1, 1); $valid = true; } } return sprintf('%s-%s', $birthdate->format('dmy'), $lastFour); } }