mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 01:32:22 +01:00
RulerZ is a PHP implementation of the Specification pattern which puts the emphasis on three main aspects: - an easy and data-agnostic DSL to define business rules and specifications, - the ability to check if a candidate satisfies a specification, - the ability to filter or query any datasource to only retrieve candidates matching a specification.
82 lines
1.4 KiB
ReStructuredText
82 lines
1.4 KiB
ReStructuredText
`Specification`_
|
|
================
|
|
|
|
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.
|
|
|
|
Sample:
|
|
^^^^^^^
|
|
|
|
- `RulerZ <https://github.com/K-Phoen/rulerz>`__
|
|
|
|
UML Diagram
|
|
-----------
|
|
|
|
.. image:: uml/uml.png
|
|
:alt: Alt Specification UML Diagram
|
|
:align: center
|
|
|
|
Code
|
|
----
|
|
|
|
You can also find these code on `GitHub`_
|
|
|
|
Item.php
|
|
|
|
.. literalinclude:: Item.php
|
|
:language: php
|
|
:linenos:
|
|
|
|
SpecificationInterface.php
|
|
|
|
.. literalinclude:: SpecificationInterface.php
|
|
:language: php
|
|
:linenos:
|
|
|
|
AbstractSpecification.php
|
|
|
|
.. literalinclude:: AbstractSpecification.php
|
|
:language: php
|
|
:linenos:
|
|
|
|
Either.php
|
|
|
|
.. literalinclude:: Either.php
|
|
:language: php
|
|
:linenos:
|
|
|
|
PriceSpecification.php
|
|
|
|
.. literalinclude:: PriceSpecification.php
|
|
:language: php
|
|
:linenos:
|
|
|
|
Plus.php
|
|
|
|
.. literalinclude:: Plus.php
|
|
:language: php
|
|
:linenos:
|
|
|
|
Not.php
|
|
|
|
.. literalinclude:: Not.php
|
|
:language: php
|
|
:linenos:
|
|
|
|
Test
|
|
----
|
|
|
|
Tests/SpecificationTest.php
|
|
|
|
.. literalinclude:: Tests/SpecificationTest.php
|
|
:language: php
|
|
:linenos:
|
|
|
|
.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/Behavioral/Specification
|
|
.. _`Specification`: http://en.wikipedia.org/wiki/Specification_pattern
|