2017 © Pedro Peláez
 

library evaluator

Symfony Expression Language for Laravel

image

periloso/evaluator

Symfony Expression Language for Laravel

  • Thursday, April 20, 2017
  • by periloso
  • Repository
  • 2 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Evaluator

Symfony Expression Language module for Laravel., (*1)

Installation

Simply update the composer.json file and run composer install., (*2)

"require": {
    "periloso/evaluator": "1.0.*"
}

Quick Installation

composer require "periloso/evaluator=1.0.*", (*3)

How To Use

Evaluating an expression

$test = [
    'foo' => 10,
    'bar' => 5
];

echo Evaluator::evaluate('foo > bar', $test); //this will return true

You can also save the expression rule., (*4)

$test = [
    'foo' => 10,
    'bar' => 5
];

Evaluator::expression()->add('test', 'foo > bar');

echo Evaluator::evaluateRule('test', $test); //this will return true

For supported expressions, visit the Symfony Expression Language Component., (*5)

Condition

Let say we want to implement 10% tax to our collection., (*6)

$item = [
    'price' => 100
];

$condition = [
    'target' => 'price',
    'action' => '10%',
    'rule' => 'price > 50'
];

Evaluator::expression()->add('tax', $condition);

$calculated = Evaluator::condition('tax', $item);

Item with multiplier., (*7)

$item = [
    'price' => 50,
    'quantity' => 2
];

$condition = [
    'target' => 'price',
    'action' => '10%',
    'rule' => 'price > 50',
    'multiplier' => 'quantity'
];

Evaluator::expression()->add('tax', $condition);

$calculated = Evaluator::condition('tax', $item);

The Versions

20/04 2017

dev-master

9999999-dev

Symfony Expression Language for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel symfony expression-language

20/04 2017

1.3.1

1.3.1.0

Symfony Expression Language for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel symfony expression-language

20/04 2017

1.3.0

1.3.0.0

Symfony Expression Language for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel symfony expression-language