kphoen/rulerz-spec-builder

Specification builder for RulerZ

1.2.0 2018-09-17 14:32 UTC

This package is auto-updated.

Last update: 2024-10-28 02:14:50 UTC


README

This library provides an object-oriented way to build Specifications for RulerZ.

Installation

composer require 'kphoen/rulerz-spec-builder'

Usage

$spec = Expr::andX(
    Expr::equals('gender', 'F'),
    Expr::moreThan('points', 3000)
);

This is equivalent to gender = "F" and points > 3000

Here is a more complex example:

$spec = Expr::orX(
    Expr::andX(
        Expr::equals('gender', 'F'),
        Expr::moreThan('points', 3000)
    ),
    Expr::andX(
        Expr::equals('gender', 'M'),
        Expr::moreThan('points', 6000)
    )
);

Which is equivalent to: (gender = "F" and points > 3000) or (gender = "M" and points > 6000)

See the Expr class for an exhaustive list of supported methods.

License

This library is under the MIT license.