Download the PHP package grmvoid/basalt-value-object without Composer
On this page you can find all versions of the php package grmvoid/basalt-value-object. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download grmvoid/basalt-value-object
More information about grmvoid/basalt-value-object
Files in grmvoid/basalt-value-object
Package basalt-value-object
Short Description A set of value objects
License MIT
Homepage https://github.com/slpxxv/value-object
Informations about the package basalt-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.
Why value objects
A primitive like int or string says nothing about what it holds. A value object gives the value a name, validates it once, and makes illegal states unrepresentable - the core idea behind value objects in Domain-Driven Design.
Value objects are compared by value, not identity ($a->equals($b)), and never change after creation, so they can be passed around and shared safely.
Requirements
- PHP 8.3, 8.4 or 8.5
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.