nepada / birth-number
Czech birth number value object.
Installs: 20 642
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=8.1.0 <8.4
- nette/utils: ^3.2@dev || ^4.0@dev
Requires (Dev)
- nepada/coding-standard: 7.12.0
- nepada/phpstan-nette-tester: 1.1
- nette/tester: 2.5.1
- php-parallel-lint/php-parallel-lint: 1.3.2
- phpstan/phpstan: 1.10.32
- phpstan/phpstan-nette: 1.2.9
- phpstan/phpstan-strict-rules: 1.5.1
- shipmonk/phpstan-rules: 2.7.0
- spaze/phpstan-disallowed-calls: 2.16.0
This package is auto-updated.
Last update: 2024-09-01 12:53:58 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.