https://github.com/phpmentors-jp/domain-commons
https://github.com/phpmentors-jp/domain-commons
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/phpmentors-jp/domain-commons
- Owner: phpmentors-jp
- License: other
- Created: 2015-04-29T04:02:36.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2019-08-08T00:48:22.000Z (almost 7 years ago)
- Last Synced: 2025-04-01T09:52:32.388Z (over 1 year ago)
- Language: PHP
- Size: 43.9 KB
- Stars: 11
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Domain Commons
Commons for domain models
[](https://travis-ci.org/phpmentors-jp/domain-commons)
[](https://insight.sensiolabs.com/projects/0e1c452e-3cd6-4e17-a6c2-77ae78a9a878)
[](https://packagist.org/packages/phpmentors/domain-commons)
[](https://packagist.org/packages/phpmentors/domain-commons)
[](https://packagist.org/packages/phpmentors/domain-commons)
# Installation
`Domain Commons` can be installed using [Composer](http://getcomposer.org/).
```
$ composer require phpmentors/domain-commons
```
# Features
## DateTime basics
### Date and Time
- Date
- DateTime
- MonthDay
- Year
- YearMonth
- HourMin
- AgeRange
### Period
- Duration
- Period
- Term
#### Traversable
- DailyTrait / DailyIteratableInterface
- MonthlyTrait / MonthlyIteratableInterface
You can define a domain specific period as follows:
```php
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
- Clock
## Matrix (Typed and Addressed)
- TypedMatrix
- AddressedMatrix
### Operation
- ZeroableInterface
## String Utility
- UniqueName
# 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 (c) 2015 GOTO Hidenori, 2015 KUBO Atsuhiro, All rights reserved.
# License
[The BSD 2-Clause License](http://opensource.org/licenses/BSD-2-Clause)