Ejemplo n.º 1
0
// max
$watch->start();
$max = $collection->max(function (OA $r) {
    return $r->bytes;
});
L::line("Biggest bytes:", $max, $watch->stop()->result());
// contains / groupby
$watch->start();
$agents = $collection->where(function (OA $r) {
    return $r->agentScalar->contains('Ubuntu');
})->groupBy(function (OA $r) {
    return $r->agent;
});
echo "\n";
foreach ($agents as $key => $items) {
    L::vd(array("agent" => $key, "count" => $items->length()));
}
echo "\n";
L::line("Grouped ubuntu agents.", $watch->stop()->result());
// distinct / skip / take
$watch->start();
$skiptake = $collection->where(function (OA $r) {
    return $r->agentScalar->contains('Android');
})->distinct(function (OA $r) {
    return $r->agent;
})->skip(3)->take(5);
L::line("Distinct by agent, skip first X records, take next Y records", $watch->stop()->result());
echo "\n";
// iterate list
$watch->start();
$skiptake->each(function (OA $r) {