georgii-web / php-typed-values
Typed value objects library for common php data types.
Installs: 905
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/georgii-web/php-typed-values
Requires
- php: >=8.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^v3.89
- pestphp/pest: ^v3.8.4
- pestphp/pest-plugin-type-coverage: ^v3.6
- phpunit/phpunit: ^11.5
- rector/rector: ^2.2
- vimeo/psalm: ^6.13.1
- dev-master
- v3.11.5
- v3.11.4
- v3.11.3
- v3.11.2
- v3.11.1
- v3.11.0
- v2.11.5
- v2.11.4
- v2.11.3
- v2.11.2
- v2.11.1
- v2.11.0
- v2.10.17
- v2.10.16
- v2.10.15
- v2.10.14
- v2.10.13
- v2.10.12
- v2.10.11
- v2.10.10
- v2.10.9
- v2.10.8
- v2.10.7
- v2.10.6
- v2.10.5
- v2.10.4
- v2.10.3
- v2.10.2
- v2.10.1
- v2.10.0
- v2.9.14
- v2.9.13
- v2.9.12
- v2.9.11
- v2.9.10
- v2.9.9
- v2.9.8
- v2.9.7
- v2.9.6
- v2.9.5
- v2.9.4
- v2.9.3
- v2.9.2
- v2.9.1
- v2.9.0
- v2.8.5
- v2.8.4
- v2.8.3
- v2.8.2
- v2.8.1
- v2.8.0
- v2.7.7
- v2.7.6
- v2.7.5
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.1
- v2.7.0
- v2.6.17
- v2.6.16
- v2.6.15
- v2.6.14
- v2.6.13
- v2.6.12
- v2.6.11
- v2.6.10
- v2.6.9
- v2.6.8
- v2.6.7
- v2.6.6
- v2.6.5
- v1.11.5
- v1.11.4
- v1.11.3
- v1.11.2
- v1.11.1
- v1.11.0
- v1.10.17
- v1.10.16
- v1.10.15
- v1.10.14
- v1.10.13
- v1.10.12
- v1.10.11
- v1.10.10
- v1.10.9
- v1.10.8
- v1.10.7
- v1.10.6
- v1.10.5
- v1.10.4
- v1.10.3
- v1.10.2
- v1.10.1
- v1.10.0
- v1.9.14
- v1.9.13
- v1.9.12
- v1.9.11
- v1.9.10
- v1.9.9
- v1.9.8
- v1.9.7
- v1.9.6
- v1.9.5
- v1.9.4
- v1.9.3
- v1.9.2
- v1.9.1
- v1.9.0
- v1.8.5
- v1.8.4
- v1.8.3
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.7
- v1.7.6
- v1.7.5
- v1.7.4
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.17
- v1.6.16
- v1.6.15
- v1.6.14
- v1.6.13
- v1.6.12
- v1.6.11
- v1.6.10
- v1.6.9
- v1.6.8
- v1.6.7
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.1
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.0
- 1.0.0
- dev-php7.4
- dev-php8.2
This package is auto-updated.
Last update: 2026-01-22 23:19:21 UTC
README
PHP Typed Values
Typed value objects for PHP. Build precise, immutable, and validated data for DTOs, Value Objects, and Entities.
Install
- Use V3 for PHP 8.4:
composer require georgii-web/php-typed-values:^3
- Use V2 for PHP >=8.2 & <8.4:
composer require georgii-web/php-typed-values:^2
- Use V1 for PHP 7.4:
composer require georgii-web/php-typed-values:^1
Why
- Strong typing for scalars with runtime validation
- Immutable and self‑documenting values
- Safer constructors for your DTOs/VOs/Entities
- Great fit for static analysis
Quick start
Use existing typed values
use PhpTypedValues\Integer\IntegerPositive; $id = IntegerPositive::fromString('123');
Instead of spreading validation across an application
$id = (int) '123'; if ($id <= 0) { throw new InvalidArgumentException('Invalid ID'); }
Create an alias (domain name)
use PhpTypedValues\Integer\IntegerPositive; readonly class Id extends IntegerPositive {} Id::fromInt(123);
Other usage examples docs/USAGE.md
Key features
- Idempotent conversion on fromString() > toString(): "1" > 1 > "1"
- Static analysis friendly
- Strict types
- Validation on construction; no invalid state
- Immutable, readonly objects
- No external runtime dependencies
- Easy to extend with your own types and composites
- Heavily tested
Performance note
- Objects vs Scalars:
- ~2.3× slower for large arrays of objects
- ~1.5× higher memory usage
- Use value objects for domain boundaries, validation, and clarity
- Use raw scalars in hot loops or large data processing paths
Documentation
- Development guide: docs/DEVELOP.md
- More usage examples in tests/Unit
License
MIT