dwo/aggregator

collect and aggregate data for statistical analysis

v1.3.3 2016-11-14 12:50 UTC

This package is not auto-updated.

Last update: 2024-04-13 16:07:05 UTC


README

Build Status Coverage Status Scrutinizer Code Quality

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
)