2017 © Pedro Peláez
 

standalone formulate

Making life easier while writing complex math formulas, take a breath

image

rezzza/formulate

Making life easier while writing complex math formulas, take a breath

  • Tuesday, May 17, 2016
  • by steph_py
  • Repository
  • 4 Watchers
  • 13 Stars
  • 28,247 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 8 Versions
  • 1 % Grown

The README.md

Formulate - PHP

Build Status, (*1)

Making life easier while writing complex math formulas, take a breath, (*2)

Install via composer

# composer.json
"rezzza/formulate": "dev-master"
# shell
php composer.phar update # or install

Usage

<?php

use Rezzza\Formulate\Formula;

$formula = new Formula('{{ variable1 }} + {{ variable2 }}');
$formula->setParameter('variable1', 10);
$formula->setParameter('variable2', 13);

echo $formula->render(); // "10 + 13"

$formula->setIsCalculable(true);

echo $formula->render(); // "23"

// Works with sub formulas

$formula = new Formula('{{ subformula1 }} + {{ variable2 }}');
$formula->setSubFormula('subformula1', new Formula('({{ variable1 }} - {{ variable2 }} / 100)'));
$formula->setParameter('variable1', 10);
$formula->setParameter('variable2', 13);

echo $formula->render(); // (10 - 13 / 100) + 13

Mathematic operations

Works as above + constant Formula::CALCULABLE, it'll use Hoa\Math arithmetic grammar to evaluate your operation. Example:, (*3)

use Rezzza\Formulate\Formula;

$formula = new Formula('{{ subformula1 }} + {{ variable2 }}');
$formula->setSubFormula('subformula1', new Formula('(30 / 2) * -10', Formula::CALCULABLE));
$formula->setParameter('variable2', '10');

echo $formula->render(); // -150 + 10

$formula->setIsCalculable(true);

echo $formula->render(); // -140

Look at Hoa Math repository., (*4)

Tests

php composer install --dev
bin/atoum -d tests/units

Todo

  • Add more tests

The Versions

17/05 2016

dev-master

9999999-dev https://github.com/rezzza/Formulate

Making life easier while writing complex math formulas, take a breath

  Sources   Download

MIT

The Requires

 

The Development Requires

math standalone formula

17/05 2016

v1.0.6

1.0.6.0 https://github.com/rezzza/Formulate

Making life easier while writing complex math formulas, take a breath

  Sources   Download

MIT

The Requires

 

The Development Requires

math standalone formula

11/03 2016

v1.0.5

1.0.5.0 https://github.com/rezzza/Formulate

Making life easier while writing complex math formulas, take a breath

  Sources   Download

MIT

The Requires

 

The Development Requires

math standalone formula

15/12 2015

v1.0.4

1.0.4.0 https://github.com/rezzza/Formulate

Making life easier while writing complex math formulas, take a breath

  Sources   Download

MIT

The Requires

 

The Development Requires

math standalone formula

18/09 2014

v1.0.3

1.0.3.0 https://github.com/rezzza/Formulate

Making life easier while writing complex math formulas, take a breath

  Sources   Download

MIT

The Requires

 

The Development Requires

math standalone formula

15/10 2013

v1.0.2

1.0.2.0 https://github.com/rezzza/Formulate

Making life easier while writing complex math formulas, take a breath

  Sources   Download

MIT

The Requires

 

The Development Requires

math standalone formula

27/08 2013

v1.0.1

1.0.1.0 https://github.com/rezzza/Formulate

Making life easier while writing complex math formulas, take a breath

  Sources   Download

MIT

The Requires

 

The Development Requires

math standalone formula

19/09 2012

v1.0.0

1.0.0.0 https://github.com/rezzza/Formulate

Making life easier while writing complex math formulas, take a breath

  Sources   Download

MIT

The Requires

 

The Development Requires

  • mageekguy/atoum dev-master

math standalone formula