PHPackages                             bus-factor/ddd - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bus-factor/ddd

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bus-factor/ddd
==============

Domain Driven Design related Classes and Utilities

v6.0.0(3y ago)19.1k1MITPHPPHP ^8.1

Since Sep 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/bus-factor/ddd)[ Packagist](https://packagist.org/packages/bus-factor/ddd)[ RSS](/packages/bus-factor-ddd/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (2)Versions (20)Used By (1)

DDD
===

[](#ddd)

Domain-Driven Design related Classes and Utilities.

[![Codacy Badge](https://camo.githubusercontent.com/099049959865720b0168ceff5089e67398d34d3260519fc9aee3dbf048f5dd49/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6661646431323133656638653430326362393633643862653866343564636461)](https://app.codacy.com/app/bus-factor/ddd?utm_source=github.com&utm_medium=referral&utm_content=bus-factor/ddd&utm_campaign=Badge_Grade_Dashboard)[![Latest Stable Version](https://camo.githubusercontent.com/22d06401da7f9983b58c8d229861bb4608f339eda3c44356c2ba0a508e0f4e67/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6275732d666163746f722f6464642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bus-factor/ddd)[![Total Downloads](https://camo.githubusercontent.com/79baa096a89cf60dba15bf5ecf9f03ca59ce1a081d3c665d4e1ead0c7477fd00/68747470733a2f2f706f7365722e707567782e6f72672f6275732d666163746f722f6464642f646f776e6c6f6164732e706e67)](https://packagist.org/packages/bus-factor/ddd)[![Minimum PHP Version](https://camo.githubusercontent.com/4f9eddea3b5f90bdf4c2f6feafb71962a03512fd923888e4aef358cf6334daf7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e322d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net/)[![Build Status](https://camo.githubusercontent.com/057712f55818b6fe918d38b9d3c659c69a158d974ee31a1f5142d742f429b40d/68747470733a2f2f7472617669732d63692e636f6d2f6275732d666163746f722f6464642e7376673f746f6b656e3d36435654684e7959393471705676754d67583346266272616e63683d6d6173746572)](https://travis-ci.com/bus-factor/ddd.svg?token=6CVThNyY94qpVvuMgX3F&branch=master)[![Coverage Status](https://camo.githubusercontent.com/878a40be4741c094aae7ddabe702f45d7c57b27739f87712001a915cb688516f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6275732d666163746f722f6464642f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/bus-factor/ddd?branch=master)

Model
-----

[](#model)

### Value Objects

[](#value-objects)

The following value object classes are available:

- `EmailAddress`
- `Enum`
- `IpAddress`
- `IpV4Address`
- `IpV6Address`
- `MacAddress`
- `SingleValueObject` (Single-value object base class)
- `Url`

Sample usage
------------

[](#sample-usage)

```
/**
 * @method static Currency EUR()
 * @method static Currency USD()
 */
class Currency extends \BusFactor\Ddd\ValueObject\Enum {
    public const EUR = 'EUR';
    public const USD = 'USD';
}

class Decimal implements \BusFactor\Ddd\ComparableInterface {
    use \BusFactor\Ddd\ComparableTrait;

    // ...
    public function compareTo(\BusFactor\Ddd\ComparableInterface $subject) : int {
    }
    // ...
}

class Money implements \BusFactor\Ddd\ComparableInterface {
    use \BusFactor\Ddd\ComparableTrait;

    /** @var Decimal $amount*/
    private $amount;
    /** @var Currency $currency */
    private $currency;

    /**
     * @param Decimal $amount
     * @param Currency $currency
     */
    public function __construct(Decimal $amount, Currency $currency) {
        $this->amount = $amount;
        $this->currency = $currency;
    }

    /**
     * @param \BusFactor\Ddd\ComparableInterface $subject
     * @return int
     */
    public function compareTo(\BusFactor\Ddd\ComparableInterface $subject) : int {
        $comparable = $subject instanceof static::class
            && $this->currency === $subject->currency;

        if (!$comparable) {
            throw new LogicException('Incompatible currencies');
        }

        return $this->amount->compareTo($subject->amount);
    }
}

$money = new Money(new Decimal(/* ... */), Currency::EUR());
$otherMoney = new Money(new Decimal(/* ... */), Currency::EUR());
```

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~78 days

Recently: every ~138 days

Total

18

Last Release

1104d ago

Major Versions

v1.0.0 → v2.0.02019-11-30

v2.0.0 → v3.0.02020-11-22

v3.0.1 → v4.0.02020-12-27

v4.0.0 → v5.0.02020-12-27

v5.5.0 → v6.0.02023-05-06

PHP version history (4 changes)v3.0.0PHP ^7.3

v5.2.0PHP &gt;=7.3

v5.4.0PHP &gt;=7.4

v6.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/44ccde1fcae320f49bcd75fd528a532212c7da3913d74926b4f6e030d4e4fe1f?d=identicon)[bus-factor](/maintainers/bus-factor)

---

Top Contributors

[![bus-factor](https://avatars.githubusercontent.com/u/16355907?v=4)](https://github.com/bus-factor "bus-factor (44 commits)")

---

Tags

Domain Driven Designddd

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bus-factor-ddd/health.svg)

```
[![Health](https://phpackages.com/badges/bus-factor-ddd/health.svg)](https://phpackages.com/packages/bus-factor-ddd)
```

###  Alternatives

[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[phpmentors/domain-kata

Kata for domain models

73426.9k9](/packages/phpmentors-domain-kata)[phpmentors/domain-commons

Commons for domain models

11287.8k](/packages/phpmentors-domain-commons)[pauci/cqrs

CQRS library

1725.2k2](/packages/pauci-cqrs)[ammardaana/laravel-domain-driven-design

Generate laravel Domain driven design (monolith) structure

111.2k](/packages/ammardaana-laravel-domain-driven-design)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
