Download the PHP package slpxxv/value-object without Composer
On this page you can find all versions of the php package slpxxv/value-object. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download slpxxv/value-object
More information about slpxxv/value-object
Files in slpxxv/value-object
Package value-object
Short Description A set of value objects
License MIT
Homepage https://github.com/slpxxv/value-object
Informations about the package value-object
Value Object
Small, strictly typed value objects for PHP applications. The package provides immutable wrappers for common scalar, identifier, date/time, and person-domain values, with validation close to the data it protects.
Requirements
- PHP 8.3 or 8.4
ext-mbstring- Composer 2
Installation
Usage
All value objects are immutable, implement Stringable, and expose their native value through value(). Invalid input throws Slpxxv\ValueObject\Exception\ValueObjectException or one of its subclasses.
Scalar values
Boolean accepts 1, true, yes, y, and on, plus their false equivalents (0, false, no, n, off). String input is case-insensitive and surrounding whitespace is ignored. Double rejects NAN and infinite values.
UUID
UUID strings are validated and normalized to their canonical lowercase representation.
Date and time
The wrapped value is a DateTimeImmutable; modifying it always creates a new value object.
Person values
First names support up to 50 characters and last names up to 100 characters. Available gender values are created with Female::create(), Male::create(), and Unspecified::create().
Development
Install dependencies and run the complete quality suite:
Individual commands are also available:
License
Released under the MIT License.