2017 © Pedro PelĂĄez
 

library satisfaction

A PHP implementation of the specification pattern for DDD

image

maximecolin/satisfaction

A PHP implementation of the specification pattern for DDD

  • Tuesday, September 12, 2017
  • by maximecolin
  • Repository
  • 5 Watchers
  • 25 Stars
  • 8,881 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 5 % Grown

The README.md

Satisfaction

Satisfaction is a PHP implementation of the Specification pattern for DDD., (*1)

Build Status, (*2)

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., (*3)

Installation

composer require maximecolin/satisfaction

Usage

Simple example

My model :, (*4)

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

My specification :, (*5)

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 :, (*6)

$specicification = new PublishedArticle();

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

Or, And, Not

You can chain specifications with "or", "and" or "not" condition., (*7)

// 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, (*8)

Licence

See the LICENCE file., (*9)

Acknowledgements

Thanks to Jean-François Lépine for his talk about DDD., (*10)

The Versions

12/09 2017

dev-master

9999999-dev http://www.maximecolin.fr

A PHP implementation of the specification pattern for DDD

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

pattern specification ddd

22/10 2015

1.0.1

1.0.1.0 http://www.maximecolin.fr

A PHP implementation of the specification pattern for DDD

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

pattern specification ddd

01/11 2014

1.0.0

1.0.0.0 http://www.maximecolin.fr

A PHP implementation of the specification pattern for DDD

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

pattern specification ddd