Skip to content

Commit

Permalink
Return zero on getAge
Browse files Browse the repository at this point in the history
  • Loading branch information
frozzare committed Sep 27, 2019
1 parent d3c6a6c commit 6699062
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Personnummer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static function format($ssn, $longFormat = false)
public static function getAge($ssn, $includeCoordinationNumber = true)
{
if (!self::valid($ssn, $includeCoordinationNumber)) {
return;
return 0;
}

$parts = self::getParts($ssn);
Expand All @@ -117,7 +117,7 @@ public static function getAge($ssn, $includeCoordinationNumber = true)
try {
$d2 = new DateTime(sprintf('%s%s-%s-%d', $parts['century'], $parts['year'], $parts['month'], $day));
} catch (Exception $e) {
return;
return 0;
}

return $d1->diff($d2)->y;
Expand Down

0 comments on commit 6699062

Please sign in to comment.