mojolyon/axiom 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mojolyon/axiom

Composer 安装命令:

composer require mojolyon/axiom

包简介

Business rule management system

README 文档

README

a simple business rule management system for php

Wikepedia definition :

A BRMS or Business Rule Management System is a software system used to define, deploy, execute, monitor and maintain the variety and complexity of decision logic that is used by operational systems within an organization or enterprise. This logic, also referred to as business rules, includes policies, requirements, and conditional statements that are used to determine the tactical actions that take place in applications and systems.

Inspired by the book Enterprise Patterns and MDA written By Jim Arlow and Ila Neustadt

Installation

Add this in your composer.json :

{
    "require": {
        "mojolyon/axiom": "~0.1"
    }
}

Usage

// Setting rule with default values
$rule = new Rule('eligibleForDiscount');
$rule->add(new RuleElement\DateVariable('minCustomerSince', new \DateTime('2014-01-01 00:00:00')))
    ->add(new RuleElement\DateVariable('customerSince', new \DateTime('2014-01-01 00:00:00')))
    ->operator(Operator::GREATHER_THAN)
    ->variable('minOrder', 5)
    ->variable('customerNumberOrder', 0)
    ->operator(Operator::LESSERTHAN_OR_EQUAL)
    ->operator('and');

$ruleContext = new Context('eligibleForDiscountCustomer');
$ruleContext->add(new RuleElement\DateVariable('customerSince', new \DateTime('2013-12-11 22:00:00')))
            ->variable('customerNumberOrder', 13);

$isEligible = $rule->evaluate($ruleContext);

if ($isEligible->getValue()) {
    echo "Customer eligible for discount";
} else {
    echo "Customer not eligible for discount";
}

// will output "Customer eligible for discount"
// the rule is evaluate as : ((minCustomerSince > customerSince) and (minOrder <= customerNumberOrder))

There is three type of rule elements :

  • Proposition : values must be a boolean
  • Variable : values can be everything
  • DateVariable : values must be an instance of DateTime

The base Rule have helper for adding elements :

  • Rule::operator()
  • Rule::proposition()
  • Rule::variable()

Tests

$ php composer.phar install --dev
$ ./vendor/bin/atoum

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固