dwo / aggregator
collect and aggregate data for statistical analysis
v1.3.3
2016-11-14 12:50 UTC
Requires
- php: >=5.3.0
- dwo/math: ~1.0
- dwo/simple_accessor: ~0.1
- symfony/property-access: >=2.0
Requires (Dev)
- dwo/tracedump: @dev
README
Aggregator
collect, group & aggregate data
$collector = new Collector(array('country')); $collector->addEntry(['country' => 'DE', 'counts'=>1]); $collector->addEntry(['country' => 'DE', 'counts'=>2]); $collector->addEntry(['country' => 'AT', 'counts'=>2]); $collector->addEntry(['country' => 'AT', 'counts'=>3]); $aggregationGroup = Aggregator::aggregate($collector); print_r($aggregationGroup->toArray());
Array ( [DE] => Array ( [country] => DE [counts] => 3 ) [AT] => Array ( [country] => AT [counts] => 5 ) )
Merger
merge two arrays
$origin = ['counts' => 1]; $merge = ['counts' => 2]; Merger::merge($origin, $merge); print_r($origin);
Array ( [counts] => 3 )