mediagone / types-common
A collection of generic Value Objects you should (always) use instead of primitive types!
Installs: 3 874
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/mediagone/types-common
Requires
- php: ^7.4|^8.0
- ext-iconv: *
- ext-json: *
- ext-mbstring: *
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5.25
This package is auto-updated.
Last update: 2025-10-26 16:43:20 UTC
README
Value Objects are small and immutable classes representing typed values usually implemented using PHP primitive types. However, objects can embed validation to ensure that your data is always valid without adding any check elsewhere in your code. That's why you should ALWAYS use Value Objects rather than primitive types!
This package provides most common types you can use in any project.
Installation
This package requires PHP 7.4+
Add it as Composer dependency:
$ composer require mediagone/types-common
Available value-objects
All value-objects implement a common ValueObject interface and JsonSerializable.
Business
BicIban
Crypto
Hash(abstract class)HashBcryptHashArgon2idRandomTokenSha512
Note: all Hash* types are based on Hash base class, so they are perfectly interoperable.
Geo
AddressCityCountryLatitudeLongitude
Graphics
Color
System
AgeBase64BinaryCountDateDateTimeUTCDayOfMonthDurationHexQuantity
Text
NameNameDigitNameSpecialSlugSlugSnakeTextTextMediumTitle
Web
EmailAddressUrlUrlHostUrlPath
License
Types Common is licensed under MIT license. See LICENSE file.