PHPackages                             phpmentors/domain-commons - 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. phpmentors/domain-commons

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

phpmentors/domain-commons
=========================

Commons for domain models

v1.1.3(8y ago)11287.8k↓29.3%4[1 PRs](https://github.com/phpmentors-jp/domain-commons/pulls)BSD-2-ClausePHPPHP &gt;=5.5

Since May 27Pushed 6y ago3 watchersCompare

[ Source](https://github.com/phpmentors-jp/domain-commons)[ Packagist](https://packagist.org/packages/phpmentors/domain-commons)[ RSS](/packages/phpmentors-domain-commons/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

Domain Commons
==============

[](#domain-commons)

Commons for domain models

[![Build Status](https://camo.githubusercontent.com/984eb578bc79d1a7525d91c45435a3bd0e480c8789f31cc3f142e575c1204337/68747470733a2f2f7472617669732d63692e6f72672f7068706d656e746f72732d6a702f646f6d61696e2d636f6d6d6f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phpmentors-jp/domain-commons)[![SensioLabsInsight](https://camo.githubusercontent.com/3dca82a646a722210e68b8bc6fc274b1db6c9efa53aaebb5717c3ef909d863dc/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f30653163343532652d336364362d346531372d613663322d3737616537386139613837382f6d696e692e706e67)](https://insight.sensiolabs.com/projects/0e1c452e-3cd6-4e17-a6c2-77ae78a9a878)[![Total Downloads](https://camo.githubusercontent.com/70fc0da5f5485abe12946954f7fccf2a4bb4737c59a4e33372afac976640d850/68747470733a2f2f706f7365722e707567782e6f72672f7068706d656e746f72732f646f6d61696e2d636f6d6d6f6e732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/phpmentors/domain-commons)[![Latest Stable Version](https://camo.githubusercontent.com/c798da920d01037660d02bf303297dfb06155afa6f755a77804067366c930422/68747470733a2f2f706f7365722e707567782e6f72672f7068706d656e746f72732f646f6d61696e2d636f6d6d6f6e732f762f737461626c652e706e67)](https://packagist.org/packages/phpmentors/domain-commons)[![Latest Unstable Version](https://camo.githubusercontent.com/d60a64299092fc323099966357cfefd31d8df89cca1107f3bfe045c55987e799/68747470733a2f2f706f7365722e707567782e6f72672f7068706d656e746f72732f646f6d61696e2d636f6d6d6f6e732f762f756e737461626c652e706e67)](https://packagist.org/packages/phpmentors/domain-commons)

Installation
============

[](#installation)

`Domain Commons` can be installed using [Composer](http://getcomposer.org/).

```
$ composer require phpmentors/domain-commons

```

Features
========

[](#features)

DateTime basics
---------------

[](#datetime-basics)

### Date and Time

[](#date-and-time)

- Date
- DateTime
- MonthDay
- Year
- YearMonth
- HourMin
- AgeRange

### Period

[](#period)

- Duration
- Period
- Term

#### Traversable

[](#traversable)

- DailyTrait / DailyIteratableInterface
- MonthlyTrait / MonthlyIteratableInterface

You can define a domain specific period as follows:

```
namespace MyDomain;

use PHPMentors\DomainCommons\DateTime\Date;
use PHPMentors\DomainCommons\DateTime\Period\DailyIteratableInterface;
use PHPMentors\DomainCommons\DateTime\Period\DailyTrait;

class DailyPeriod extends Period implements DailyIteratableInterface
{
    use DailyTrait;

    public function __construct(Date $start, Date $end)
    {
        parent::__construct($start, $end);
        $this->it = $this->iterate(); // this line enables iterator
    }
}
```

You can iterate this period by date using standard `foreach` statement as follows:

```
use PHPMentors\DomainCommons\DateTime\Date;
use MyDomain\DailyPeriod;

$period = new DailyPeriod(new Date('2015-04-12'), new Date('2015-06-30'));

$count = 0;
foreach ($period as $one) {
    echo $one->format('m/d') . PHP_EOL;
}

```

### Utility

[](#utility)

- Clock

Matrix (Typed and Addressed)
----------------------------

[](#matrix-typed-and-addressed)

- TypedMatrix
- AddressedMatrix

### Operation

[](#operation)

- ZeroableInterface

String Utility
--------------

[](#string-utility)

- UniqueName

Support
=======

[](#support)

If you find a bug or have a question, or want to request a feature, create an issue or pull request for it on [Issues](https://github.com/phpmentors-jp/domain-commons/issues).

Copyright
=========

[](#copyright)

Copyright (c) 2015 GOTO Hidenori, 2015 KUBO Atsuhiro, All rights reserved.

License
=======

[](#license)

[The BSD 2-Clause License](http://opensource.org/licenses/BSD-2-Clause)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 52.3% 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 ~183 days

Total

5

Last Release

3274d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6a68a4dab8a48ed7cea7379e065bbe9cbb2c68a6718c9d678afa8e0d261f1255?d=identicon)[hidenorigoto](/maintainers/hidenorigoto)

![](https://avatars.githubusercontent.com/u/52985?v=4)[Atsuhiro Kubo](/maintainers/iteman)[@iteman](https://github.com/iteman)

---

Top Contributors

[![hidenorigoto](https://avatars.githubusercontent.com/u/89830?v=4)](https://github.com/hidenorigoto "hidenorigoto (23 commits)")[![iteman](https://avatars.githubusercontent.com/u/52985?v=4)](https://github.com/iteman "iteman (20 commits)")[![77web](https://avatars.githubusercontent.com/u/296615?v=4)](https://github.com/77web "77web (1 commits)")

---

Tags

datetimeDomain Driven Designddddesignmodeling

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpmentors-domain-commons/health.svg)

```
[![Health](https://phpackages.com/badges/phpmentors-domain-commons/health.svg)](https://phpackages.com/packages/phpmentors-domain-commons)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[phpmentors/domain-kata

Kata for domain models

73426.9k9](/packages/phpmentors-domain-kata)[thejano/laravel-domain-driven-design

Helps to use domain driven design within laravel

15423.8k](/packages/thejano-laravel-domain-driven-design)[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)
