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-09-18 15:12:47 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);
    }
}

License

MIT