Search by

cohete / ddd

pascualmg

Opinionated DDD building blocks for Cohete

v0.1.0 2026-03-12 18:14 UTC

This package is auto-updated.

Last update: 2026-12-04 21:23:58 UTC


README

CI

Opinionated DDD building blocks for Cohete.

Installation

composer require cohete/ddd

Value Objects

  • StringValueObject - Base class for string VOs with validation (maxLength, notNull, notEmpty)
  • UuidValueObject - UUID v4 via ramsey/uuid
  • AtomDateValueObject - Dates in ATOM format

Example: custom Value Object

use Cohete\DDD\ValueObject\StringValueObject;

class UserEmail extends StringValueObject
{
    public static function from(?string $value = null): static
    {
        static::assertNotNull($value);
        static::assertNotEmpty($value);
        static::assertMaxLength(255, $value);

        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
            throw new \InvalidArgumentException("Invalid email: $value");
        }

        return parent::from($value);
    }
}

Requirements and PHP matrix

PHP 8.2 to 8.5 ("php": "^8.2"). Every version is tested with nix flake check, which runs the tests and PHPStan in one check per PHP version: 8.2, 8.3, 8.4 and 8.5. Dependencies are pinned by composer.lock and fetched once in a fixed-output derivation shared by all the checks.

nix develop                 # shell with PHP 8.5 and Composer (nix develop .#php82 for another version)
composer install
nix run .#test-php85        # phpunit with one version (test-php82, test-php83, test-php84, test-php85)
nix flake check             # the whole matrix

License

MIT