cohete/ddd

Opinionated DDD building blocks for Cohete

Maintainers

Package info

github.com/pascualmg/cohete-ddd

pkg:composer/cohete/ddd

Statistics

Installs: 0

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-03-12 18:14 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