Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Herzult/SimplePHPEasyPlus
A simple, pragmatic numeric operation api written in PHP. It does addition.
https://github.com/Herzult/SimplePHPEasyPlus
Last synced: 3 months ago
JSON representation
A simple, pragmatic numeric operation api written in PHP. It does addition.
- Host: GitHub
- URL: https://github.com/Herzult/SimplePHPEasyPlus
- Owner: Herzult
- License: mit
- Created: 2010-12-06T19:02:12.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2020-10-02T06:36:38.000Z (over 4 years ago)
- Last Synced: 2024-08-02T20:57:25.450Z (6 months ago)
- Language: PHP
- Homepage:
- Size: 261 KB
- Stars: 1,163
- Watchers: 40
- Forks: 46
- Open Issues: 32
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
- awesome-hilarious-repos - Simple easy PHP plus 2 numbers (wtf) - the best enterprised and standadized code to sum to numbers in PHP! (Libraries, Frameworks and SDKs)
README
### This awesome yet simple and pragmatic PHP library performs an addition of two numbers.
[![Build Status](https://secure.travis-ci.org/Herzult/SimplePHPEasyPlus.png)](http://travis-ci.org/Herzult/SimplePHPEasyPlus)
In early stages of Internet, developers were forced to work with poor, dry, imperative, horrific languages.
Everything had to be done through austere functions and operators. There was no objects. No interfaces. No dependency injection.For example, to make something as simple as an addition, our dads had to write: `1+1`.
Yeah, really.Hopefuly now, we have PHP 5.3 and its solid OOP implementation.
SimplePHPEasyPlus lets you make this addition in a more fashionable way, using real OOP.
It is fast, simple, flexible and tested. To add `1` to `1`, all you have to do is:```php
use SimplePHPEasyPlus\Number\NumberCollection;
use SimplePHPEasyPlus\Number\SimpleNumber;
use SimplePHPEasyPlus\Number\CollectionItemNumberProxy;
use SimplePHPEasyPlus\Parser\SimpleNumberStringParser;
use SimplePHPEasyPlus\Iterator\CallbackIterator;
use SimplePHPEasyPlus\Operator\AdditionOperator;
use SimplePHPEasyPlus\Operation\ArithmeticOperation;
use SimplePHPEasyPlus\Operation\OperationStream;
use SimplePHPEasyPlus\Engine;
use SimplePHPEasyPlus\Calcul\Calcul;
use SimplePHPEasyPlus\Calcul\CalculRunner;$numberCollection = new NumberCollection();
$numberParser = new SimpleNumberStringParser();
$firstParsedNumber = $numberParser->parse('1');
$firstNumber = new SimpleNumber($firstParsedNumber);
$firstNumberProxy = new CollectionItemNumberProxy($firstNumber);$numberCollection->add($firstNumberProxy);
$secondParsedNumber = $numberParser->parse('1');
$secondNumber = new SimpleNumber($secondParsedNumber);
$secondNumberProxy = new CollectionItemNumberProxy($secondNumber);$numberCollection->add($secondNumberProxy);
$addition = new AdditionOperator('SimplePHPEasyPlus\Number\SimpleNumber');
$operation = new ArithmeticOperation($addition);
$engine = new Engine($operation);
$calcul = new Calcul($engine, $numberCollection);
$runner = new CalculRunner();
$runner->run($calcul);
$result = $calcul->getResult();
$numericResult = $result->getValue(); // 2
```This library is now available for production purposes. Enjoy!