https://github.com/mathematicator-core/calculator
Modular advance calculations layer.
https://github.com/mathematicator-core/calculator
arithmetic calculator computing equation math number-theory
Last synced: 2 months ago
JSON representation
Modular advance calculations layer.
- Host: GitHub
- URL: https://github.com/mathematicator-core/calculator
- Owner: mathematicator-core
- License: mit
- Created: 2019-07-25T16:09:26.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-02T04:59:42.000Z (over 2 years ago)
- Last Synced: 2024-09-14T00:35:10.057Z (about 1 year ago)
- Topics: arithmetic, calculator, computing, equation, math, number-theory
- Language: PHP
- Homepage: https://baraja.cz
- Size: 159 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/funding.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Advance PHP Calculator[](https://github.com/mathematicator-core/calculator/actions?query=workflow%3A%22Integrity+check%22)
[](https://codecov.io/gh/mathematicator-core/calculator)
[](https://packagist.org/packages/mathematicator-core/calculator)
[](https://packagist.org/packages/mathematicator-core/calculator)
[](./LICENSE)
[](https://phpstan.org/)Simple to use **modular calculator** with **steps to solution** and **result explanation**.
It is highly recommended to make sure you have enabled [BCMath](https://www.php.net/manual/en/book.bc.php)
or [GMP](https://www.php.net/manual/en/book.gmp.php) extension on your PHP server for much
faster calculations.## Installation
```
composer require mathematicator-core/calculator
```## Idea
Imagine you want compute some math problem, for instance:
```
(5 + 3) * (2 / (7 + 3))
```How to compute it? Very simply:
```php
$calculator = new Calculator(/* some dependencies */);echo $calculator->calculateString('(5 + 3) * (2 / (7 + 3))'); // \frac{8}{5}
```Method `calculateString()` returns entity `CalculatorResult` that implements `__toString()` method.
Advance use is by an array of tokens created by `Tokenizer`:
```php
$tokenizer = new Tokenizer(/* some dependencies */);// Convert math formule to array of tokens:
$tokens = $tokenizer->tokenize('(5+3)*(2/(7+3))');// Now you can convert tokens to more useful format:
$objectTokens = $tokenizer->tokensToObject($tokens);$calculator->calculate($objectTokens);
```## Mathematicator Framework tools structure
The biggest advantage is that you can choose which layer best fits
your needs and start build on the top of it, immediately, without the need
to create everything by yourself. Our tools are tested for bugs
and tuned for performance, so you can save a significant amount
of your time, money, and effort.Framework tend to be modular as much as possible, so you should be able
to create an extension on each layer and its sublayers.**Mathematicator framework layers** ordered from the most concrete
one to the most abstract one:
Search
Modular search engine layer that calls its sublayers
and creates user interface.
Vizualizator
Elegant graphic visualizer that can render to
SVG, PNG, JPG and Base64.
Extensions:
Mandelbrot set generator
Calculator
Modular advance calculations layer.
Extensions:
Integral Solver
,
Statistics
Engine
Core logic layer that maintains basic controllers,
DAOs, translator, common exceptions, routing etc.
Tokenizer
Tokenizer that can convert string (user input / LaTeX) to numbers
and operators.
Numbers
Fast & secure storage for numbers with arbitrary precision.
It supports Human string and LaTeX output and basic conversions.
**Third-party packages:**
⚠️ Not guaranteed!
REST API
Install the whole pack as a REST API service
on your server (Docker ready) or
access it via public cloud REST API.
## Contribution
> Please help improve this documentation by sending a Pull request.
### Tests
All new contributions should have its unit tests in `/tests` directory.
Before you send a PR, please, check all tests pass.
This package uses [Nette Tester](https://tester.nette.org/). You can run tests via command:
```bash
composer test
````Before PR, please run complete code check via command:
```bash
composer cs:install # only first time
composer fix # otherwise pre-commit hook can fail
````