nepada / birth-number-doctrine
Czech birth number type for Doctrine.
Installs: 1 738
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=8.1.0 <8.5
- doctrine/dbal: ^3.4@dev || ^4.0@dev
- nepada/birth-number: ^1.0@dev
Requires (Dev)
- composer-runtime-api: ^2.0
- composer/semver: 3.4.3
- mockery/mockery: 1.6.12
- nepada/coding-standard: 7.14.0
- nepada/phpstan-nette-tester: 1.2.1
- nette/tester: 2.5.4
- nette/utils: >=3.2.7
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpstan/phpstan: 1.12.7
- phpstan/phpstan-mockery: 1.1.3
- phpstan/phpstan-nette: 1.3.8
- phpstan/phpstan-strict-rules: 1.6.1
- shipmonk/phpstan-rules: 3.2.1
- spaze/phpstan-disallowed-calls: 3.5.1
This package is auto-updated.
Last update: 2024-12-01 03:57:15 UTC
README
Installation
Via Composer:
$ composer require nepada/birth-number-doctrine
Register the type in your bootstrap:
\Doctrine\DBAL\Types\Type::addType( \Nepada\BirthNumberDoctrine\BirthNumberType::NAME, \Nepada\BirthNumberDoctrine\BirthNumberType::class );
In Nette with nettrine/dbal integration, you can register the types in your configuration:
dbal: connection: types: Nepada\BirthNumber\BirthNumber: Nepada\BirthNumberDoctrine\BirthNumberType
Usage
BirthNumberType
maps database value to Birth number value object (see nepada/birth-number for further details) and back. The Birth number is stored as fixed string without the slash (e.g. 0001010009
).
Example usage in the entity:
use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Nepada\BirthNumber\BirthNumber; #[Entity] class Person { #[Column(type: BirthNumber::class, nullable: false)] private BirthNumber $birthNumber; public function getBirthNumber(): BirthNumber { return $this->birthNumber; } }
Example usage in query builder:
$result = $repository->createQueryBuilder('foo') ->select('foo') ->where('foo.birthNumber = :birthNumber') // the parameter value is automatically normalized to '0001010009' ->setParameter('birthNumber', '000101 / 0009', BirthNumberType::NAME) ->getQuery() ->getResult();