Skip to content

Files

Latest commit

e204e0d · Dec 19, 2024

History

History
This branch is up to date with DesignPatternsPHP/DesignPatternsPHP:main.

Specification

README.rst

Purpose

Builds a clear specification of business rules, where objects can be checked against. The composite specification class has one method called isSatisfiedBy that returns either true or false depending on whether the given object satisfies the specification.

UML Diagram

Alt Specification UML Diagram

Code

You can also find this code on GitHub

Item.php

.. literalinclude:: Item.php
   :language: php
   :linenos:

Specification.php

.. literalinclude:: Specification.php
   :language: php
   :linenos:

OrSpecification.php

.. literalinclude:: OrSpecification.php
   :language: php
   :linenos:

PriceSpecification.php

.. literalinclude:: PriceSpecification.php
   :language: php
   :linenos:

AndSpecification.php

.. literalinclude:: AndSpecification.php
   :language: php
   :linenos:

NotSpecification.php

.. literalinclude:: NotSpecification.php
   :language: php
   :linenos:

Test

Tests/SpecificationTest.php

.. literalinclude:: Tests/SpecificationTest.php
   :language: php
   :linenos: