Via Composer:
$ composer require nepada/birth-number
The parser is quite benevolent with regard to the delimiter separating the ending of birth number.
$birthNumber = Nepada\BirthNumber\BirthNumber::fromString('0421010030');
$birthNumber = Nepada\BirthNumber\BirthNumber::fromString('042101/0030');
$birthNumber = Nepada\BirthNumber\BirthNumber::fromString('042101 0030');
$birthNumber = Nepada\BirthNumber\BirthNumber::fromString('042101 / 0030');
Nepada\BirthNumber\InvalidBirthNumberException
is thrown in case of invalid input value.
echo((string) $birthNumber); // '042101/0030'
echo($birthNumber->toString()); // '042101/0030'
echo($birthNumber->toStringWithoutSlash()); // '0421010030'
Nepada\BirthNumber\BirthNumber::isValid('0421010030'); // true
Nepada\BirthNumber\BirthNumber::isValid('9999999999'); // false
$birthNumber1 = Nepada\BirthNumber\BirthNumber::fromString('042101/0030');
$birthNumber2 = Nepada\BirthNumber\BirthNumber::fromString('042101/0030');
$birthNumber1->equals($birthNumber2); // true
$birthNumber = Nepada\BirthNumber\BirthNumber::fromString('047101 / 0090');
$birthNumber->getBirthDate(); // \DateTimeImmutable('2004-01-01')
$gender = $birthNumber->getGender(); // Nepada\BirthNumber\Gender enum instance
$gender->isFemale(); // true
$gender->isMale(); // false
$gender->toString(); // 'female'
- nepada/birth-number-doctrine - Birth number type for Doctrine.
- nepada/birth-number-input - Birth number form input for Nette forms.