msstc4php / vo-organisations-doctrine
Doctrine ORM and MongoDB ODM types for msstc4php/vo-organisations.
Package info
github.com/msstc4php/vo-organisations-doctrine
pkg:composer/msstc4php/vo-organisations-doctrine
Requires
- php: >=8.4
- msstc4php/vo-base-doctrine: ^1.3
- msstc4php/vo-organisations: ^0.1
Requires (Dev)
- doctrine/dbal: ^4.4
- doctrine/mongodb-odm: ^2.9
- doctrine/orm: ^3.3
- friendsofphp/php-cs-fixer: ^3.76
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-doctrine: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: >=11.0
- rector/rector: ^2.1
- roave/security-advisories: dev-latest
Suggests
- doctrine/dbal: To persist the organisation value objects as Doctrine ORM column types.
- doctrine/mongodb-odm: To persist the organisation value objects with Doctrine MongoDB ODM.
- doctrine/orm: To map the organisation value objects with Doctrine ORM.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-28 14:54:58 UTC
README
Doctrine ORM (DBAL) and MongoDB ODM types for msstc4php/vo-organisations, built on
msstc4php/vo-base-doctrine. PHP >= 8.4, no Symfony dependency.
Status: 0.x. Names and lengths are drafted to freeze at 1.0; see Backward compatibility.
22 types per branch, one per value object of vo-organisations (company, tax and business registration numbers). The
factories (AU\BusinessIdentifierFactory, RU\RegistrationNumberFactory) are not value objects and get no type.
Install
Not on Packagist yet; register the GitHub repositories:
{
"repositories": [
{ "type": "vcs", "url": "https://github.com/msstc4php/vo-base" },
{ "type": "vcs", "url": "https://github.com/msstc4php/vo-base-doctrine" },
{ "type": "vcs", "url": "https://github.com/msstc4php/vo-organisations" },
{ "type": "vcs", "url": "https://github.com/msstc4php/vo-organisations-doctrine" }
],
"require": {
"msstc4php/vo-organisations-doctrine": "^0.1"
}
}
Runtime requirements: msstc4php/vo-organisations ^0.1, msstc4php/vo-base-doctrine ^1.3; doctrine/dbal (ORM) or
doctrine/mongodb-odm (ODM) is yours.
Usage
Bare Doctrine: call Orm\TypeRegistrar::registerAll() (or Odm\TypeRegistrar::registerAll()) once at bootstrap.
Symfony: map TypeRegistrar::types() under doctrine.dbal.types (ORM) or the top-level doctrine_mongodb.types (ODM).
#[ORM\Column(type: 'org_br_cnpj')] private Cnpj $cnpj;
Type names and lengths
Every name is org_<cc>_<snake_name>; the type classes are flat and country-prefixed (Orm\AuAbnType,
Odm\EuVatNumberType) because short names collide (EU\VatNumber, GB\VatNumber). The ORM column is VARCHAR(n), n
being the class's public MAX_LENGTH (characters). The ODM field is a BSON string without a length.
The canonical unformatted value is stored (12.abc.345/01de-35 is stored as 12ABC34501DE35); there are no codecs.
The full canonical value is stored; the value objects have no masked().
Characters, not bytes. MX\LegalEntityRfc may hold Ñ, two bytes in UTF-8. Oracle sizes VARCHAR2(n) in bytes by
default and SQL Server VARCHAR(n) without a UTF-8 collation too, so a 12-character RFC with Ñ can overflow the
column (ORA-12899). Use character-length semantics (Oracle NLS_LENGTH_SEMANTICS=CHAR, SQL Server NVARCHAR or a UTF-8
collation).
On write a type accepts only its own value-object class; a plain string or another class throws
InvalidArgumentException. A stored value that no longer parses throws the value object's own exception on read.
| Type name | Value object | Column length | Length derived from |
|---|---|---|---|
org_au_abn |
AU\Abn |
11 | Abn::MAX_LENGTH, 11 digits |
org_au_acn |
AU\Acn |
9 | Acn::MAX_LENGTH, 9 digits |
org_br_cnpj |
BR\Cnpj |
14 | Cnpj::MAX_LENGTH, 12 alphanumeric + 2 digits |
org_ch_uid |
CH\Uid |
12 | Uid::MAX_LENGTH, CHE + 9 digits |
org_cn_unified_social_credit_code |
CN\UnifiedSocialCreditCode |
18 | UnifiedSocialCreditCode::MAX_LENGTH, 18 characters |
org_eu_vat_number |
EU\VatNumber |
14 | VatNumber::MAX_LENGTH, VIES prefix + up to 12 characters |
org_fr_siren |
FR\Siren |
9 | Siren::MAX_LENGTH, 9 digits |
org_fr_siret |
FR\Siret |
14 | Siret::MAX_LENGTH, 14 digits |
org_gb_company_number |
GB\CompanyNumber |
8 | CompanyNumber::MAX_LENGTH, 8 characters |
org_gb_vat_number |
GB\VatNumber |
12 | VatNumber::MAX_LENGTH, 9 or 12 digits, or GD/HA and 3 digits |
org_in_gstin |
IN\Gstin |
15 | Gstin::MAX_LENGTH, 15 characters |
org_it_partita_iva |
IT\PartitaIva |
11 | PartitaIva::MAX_LENGTH, 11 digits |
org_jp_corporate_number |
JP\CorporateNumber |
13 | CorporateNumber::MAX_LENGTH, 13 digits |
org_jp_qualified_invoice_issuer_number |
JP\QualifiedInvoiceIssuerNumber |
14 | QualifiedInvoiceIssuerNumber::MAX_LENGTH, T + 13 digits |
org_mx_legal_entity_rfc |
MX\LegalEntityRfc |
12 | LegalEntityRfc::MAX_LENGTH, 12 characters, Ñ and & allowed |
org_pl_nip |
PL\Nip |
10 | Nip::MAX_LENGTH, 10 digits |
org_pl_regon |
PL\Regon |
14 | Regon::MAX_LENGTH, 9 or 14 digits |
org_ru_ogrn |
RU\Ogrn |
13 | Ogrn::MAX_LENGTH, 13 digits |
org_ru_ogrnip |
RU\Ogrnip |
15 | Ogrnip::MAX_LENGTH, 15 digits |
org_ru_legal_entity_inn |
RU\LegalEntityInn |
10 | LegalEntityInn::MAX_LENGTH, 10 digits |
org_ru_kpp |
RU\Kpp |
9 | Kpp::MAX_LENGTH, 9 characters |
org_us_ein |
US\Ein |
9 | Ein::MAX_LENGTH, 9 digits |
Backward compatibility
0.x: names and lengths may still change. Drafted for 1.0: the type names (org_*) and ORM column lengths freeze for 1.x,
a minor release never changes the SQL declaration, and a type for a new vo-organisations class comes in a minor
release. vo-organisations never refuses in a minor a value an earlier release accepted, so stored rows keep hydrating.