timitao/value-object

Installs: 1 501

Dependents: 4

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 1

pkg:composer/timitao/value-object

v0.3.3 2021-10-12 22:08 UTC

This package is auto-updated.

Last update: 2026-02-19 07:09:18 UTC


README

License Latest Stable Version Total Downloads Scrutinizer Code Quality

Why

This library provides typed Value Objects in the spirit of Domain-Driven Design: immutable, compared by value and by type. It keeps contracts (interfaces) separate from implementations, offers both Required (non-null) and Nullable variants, and has no framework dependency—you can depend only on the contract package or use the default implementations.

Installation

composer require timitao/value-object

Usage

Extend one of the standard value object classes and use equals() for type-safe value comparison (same concrete class and same value):

use TimiTao\ValueObject\Standard\Required\AbstractClass\ValueObject\StringValueObject;

final class Title extends StringValueObject {}

$a = new Title('Hello');
$b = new Title('Hello');
$c = new Title('World');

$a->equals($b); // true — same class, same value
$a->equals($c); // false — same class, different value

Architecture decision records

  1. Record architecture decisions
  2. Strict code style
  3. Use of Beberlei/assert library
  4. Split nullable and standard in 2 namespaces
  5. Change facade for Beberlei extension uses

Versioning

Staring version 1.0.0, will follow Semantic Versioning v2.0.0.

Contributors

  • Tomasz Kunicki TimiTao [lead developer]