Download .zip |
Info | Documentation | View files (25) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2019-01-24 (Yesterday) | Not yet rated by the users | Total: Not yet counted | Not yet ranked |
Version | License | PHP version | Categories | |||
formula 0.3.0 | Custom (specified... | 7.1 | Math, Parsers, PHP 7 |
Description | Author | |
This package can parse and evaluate formulas with variables. |
Simple mathematical expression parser
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist seregas/formula "*"
or add
"seregas/formula": "*"
to the require section of your composer.json
file.
Once the extension is installed, simply use it in your code by :
$parser = new \socialist\formula\Formula('2 + 3 * 2,65 + 25 - 26');
$parser->calculate(); // 8.95
Also in the formula you can use variables:
$parser = new \socialist\formula\Formula('2 + 3 * p + 25 - 26');
$parser->setVariable('p', 2,65);
$parser->calculate(); // 8.95
And insert comments like /.../
, [...]
or {...}
:
$parser = new \socialist\formula\Formula('2 + 3 p / price */ + 25 - 26');
$parser->setVariable('p', 2,65);
$parser->calculate(); // 8.95
Files |
File | Role | Description | ||
---|---|---|---|---|
src (3 files, 2 directories) | ||||
tests (5 files, 1 directory) | ||||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
expression (5 files) | ||||
operator (5 files) | ||||
ExpressionFactory.php | Class | Class source | ||
ExpressionNotFoundException.php | Class | Class source | ||
Formula.php | Class | Class source |
Files | / | src | / | expression |
File | Role | Description |
---|---|---|
Division.php | Class | Class source |
Increment.php | Class | Class source |
Multiplication.php | Class | Class source |
Operator.php | Class | Class source |
Subtraction.php | Class | Class source |
Files | / | src | / | operator |
File | Role | Description |
---|---|---|
Double.php | Class | Class source |
Expression.php | Class | Class source |
Integer.php | Class | Class source |
Percent.php | Class | Class source |
Variable.php | Class | Class source |
Files | / | tests |
File | Role | Description | ||
---|---|---|---|---|
operator (1 file) | ||||
DoubleTest.php | Class | Class source | ||
FormulaTest.php | Class | Class source | ||
IntegerTest.php | Class | Class source | ||
PersentTest.php | Class | Class source | ||
VariableTest.php | Class | Class source |
Version Control | Unique User Downloads | |||||||
100% |
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.