Herzult / SimplePHPEasyPlus

A simple, pragmatic numeric operation api written in PHP. It does addition.
MIT License
1.16k stars 46 forks source link

Introduce simple NumberCollectionBuilder to simplify collection creation #13

Closed igorw closed 11 years ago

igorw commented 11 years ago

This CollectionBuilder can take factories for the SimpleNumberStringParser, the Number (usually a SimpleNumberFactory) and the CollectionItemNumberProxy.

For each added number, it will get an instance of each of these from the factory, to build the CollectionItems that are then added to the NumberCollection.

This change includes full test coverage.

This should vastly simplify the construction of NumberCollections.

Sample usage:

$numberCollectionBuilder = new NumberCollectionBuilder(
    new SimpleNumberStringParserFactory(),
    new SimpleNumberFactory(),
    new CollectionItemNumberProxyFactory()
);
$numberCollectionBuilder->add('2');
$numberCollectionBuilder->add('3');

$numberCollection = $numberCollectionBuilder->resolve();
Herzult commented 11 years ago

What a great addition!