定制 maximecolin/satisfaction 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maximecolin/satisfaction

Composer 安装命令:

composer require maximecolin/satisfaction

包简介

A PHP implementation of the specification pattern for DDD

README 文档

README

Satisfaction is a PHP implementation of the Specification pattern for DDD.

Build Status

Purpose

The aim of the specification pattern is to write domain specifications in reusable classes instead of dispatching domain rules conditons in all your project.

Installation

composer require maximecolin/satisfaction

Usage

Simple example

My model :

class Article
{
	public $published = false;
	public $publishedAt;
}

My specification :

use Satisfaction\CompositeSpecification;

class PublishedArticle extends CompositeSpecification
{
	public function isSatisfiedBy($article)
	{
		return $article->published === true && $article->publishedAt <= new \DateTime();
	}
}

I want to know if an article is published :

$specicification = new PublishedArticle();

if ($specification->isSatisfiedBy($article)) {
	// Do something
}

Or, And, Not

You can chain specifications with "or", "and" or "not" condition.

// If both foo and bar are satified
if ((new FooSpecification())->andX(new BarSpecification())->isSatifiedBy($object)) {
	// Do something
}
// If foo is satisfied or bar is not
if ((new FooSpecification())->orX((new BarSpecification())->not())->isSatifiedBy($object)) {
	// Do something
}

Author

Maxime Colin <www.maximecolin.fr>

Licence

See the LICENCE file.

Acknowledgements

Thanks to Jean-François Lépine for his talk about DDD.

统计信息

  • 总下载量: 30.65k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 36
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 35
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固