nepada / birth-number-doctrine
Czech birth number type for Doctrine.
Installs: 1 655
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=8.1.0 <8.4
- 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.0
- mockery/mockery: 1.6.11
- nepada/coding-standard: 7.14.0
- nepada/phpstan-nette-tester: 1.1.0
- nette/tester: 2.5.2
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpstan/phpstan: 1.10.66
- phpstan/phpstan-mockery: 1.1.2
- phpstan/phpstan-nette: 1.2.9
- phpstan/phpstan-strict-rules: 1.5.2
- shipmonk/phpstan-rules: 2.11.3
- spaze/phpstan-disallowed-calls: 3.1.2
This package is auto-updated.
Last update: 2024-09-01 03:43:27 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();