nepada / birth-number
Czech birth number value object.
Installs: 21 780
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=8.1.0 <8.5
- nette/utils: ^3.2@dev || ^4.0@dev
Requires (Dev)
- nepada/coding-standard: 7.14.0
- nepada/phpstan-nette-tester: 1.2.1
- nette/tester: 2.5.4
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpstan/phpstan: 1.12.5
- phpstan/phpstan-nette: 1.3.8
- phpstan/phpstan-strict-rules: 1.6.1
- shipmonk/phpstan-rules: 3.2.0
- spaze/phpstan-disallowed-calls: 3.4.0
This package is auto-updated.
Last update: 2024-12-01 12:21:48 UTC
README
Installation
Via Composer:
$ composer require nepada/birth-number
Usage
Creating value object
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.
Converting back to string
echo((string) $birthNumber); // '042101/0030' echo($birthNumber->toString()); // '042101/0030' echo($birthNumber->toStringWithoutSlash()); // '0421010030'
Validation
Nepada\BirthNumber\BirthNumber::isValid('0421010030'); // true Nepada\BirthNumber\BirthNumber::isValid('9999999999'); // false
Comparison
$birthNumber1 = Nepada\BirthNumber\BirthNumber::fromString('042101/0030'); $birthNumber2 = Nepada\BirthNumber\BirthNumber::fromString('042101/0030'); $birthNumber1->equals($birthNumber2); // true
Extracting information from birth number
$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'
Integrations
- nepada/birth-number-doctrine - Birth number type for Doctrine.
- nepada/birth-number-input - Birth number form input for Nette forms.