public function testNumberCollectionBuilding()
 {
     $numberCollectionBuilder = new NumberCollectionBuilder(new SimpleNumberStringParserFactory(), new SimpleNumberFactory(), new CollectionItemNumberProxyFactory());
     $numberCollectionBuilder->add('2');
     $numberCollectionBuilder->add('3');
     $numberCollection = $numberCollectionBuilder->resolve();
     $expected = new NumberCollection();
     $expected->add(new CollectionItemNumberProxy(new SimpleNumber(2.0)));
     $expected->add(new CollectionItemNumberProxy(new SimpleNumber(3.0)));
     $this->assertEquals($expected, $numberCollection);
 }
 public function resolve()
 {
     $numberCollection = new NumberCollection();
     foreach ($this->stringNumbers as $stringNumber) {
         $parser = $this->parserFactory->createParser();
         $parsed = $parser->parse($stringNumber);
         $number = $this->simpleNumberFactory->createNumber($parsed);
         $collectionItem = $this->collectionItemNumberProxyFactory->createCollectionItem($number);
         $numberCollection->add($collectionItem);
     }
     return $numberCollection;
 }
 public function testNumberCollectionCanNotContainMoreThanTwoNumbers()
 {
     $number = new SimpleNumber(1.0);
     $proxy = new CollectionItemNumberProxy($number);
     $collection = new NumberCollection();
     $collection->add(clone $proxy);
     $collection->add(clone $proxy);
     try {
         $collection->add(clone $proxy);
     } catch (OutOfRangeException $expected) {
         return;
     }
     $this->fail('Excpected out of range exception has not been raised.');
 }
function process($a, $b)
{
    $numberCollection = new NumberCollection();
    $numberParser = new SimpleNumberStringParser();
    $firstParsedNumber = $numberParser->parse('2');
    $firstNumber = new SimpleNumber($firstParsedNumber);
    $firstNumberProxy = new CollectionItemNumberProxy($firstNumber);
    $numberCollection->add($firstNumberProxy);
    $secondParsedNumber = $numberParser->parse('3');
    $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();
}
 /**
  * @param NumberCollection $collection
  *
  * @return \SimplePHPEasyPlus\Number\NumberInterface
  */
 public function operate(NumberCollection $collection)
 {
     return $this->getOperator()->process($collection->getFirstItem(), $collection->getSecondItem());
 }