- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
This awesome yet simple and pragmatic PHP library performs an addition of two numbers.
In early stages of Internet, developers were forced to work with poor, dry, functional, 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:
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!
Кто разобьёт аффтору розовые очки? )
I’m sure you’re asking yourself, “how can the enterprise gem promise so much?”. Well the answer is easy, through the magic of XML! The enterprise gem allows you to write your Ruby code in XML, therefore making your Ruby and Rails code scale. Benefits of writing your code in XML include:
It’s easy to read!
It scales!
Cross platform
TRANSFORM! your code using XSLT!
Search your AST with XPath or CSS!
The enterprise gem even comes with a handy “enterprise” binary to help you start converting your existing legacy Ruby code in to scaleable, easy to read XML files. Let’s start getting rid of that nasty Ruby code and replacing it with XML today!
https://github.com/Herzult/SimplePHPEasyPlus