Summary   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A trkSummary() 0 14 3
1
<?php
2
/**
3
 * Trunking of "summary"
4
 * User: moyo
5
 * Date: 2018/5/19
6
 * Time: 1:03 PM
7
 */
8
9
namespace Carno\Monitor\Chips\Trunks;
10
11
trait Summary
12
{
13
    /**
14
     * @param array $input
15
     * @param array $output
16
     */
17
    protected function trkSummary(array $input, array &$output) : void
18
    {
19
        if (empty($output)) {
20
            $output = $input;
21
            return;
22
        }
23
24
        $output['count'] += $input['count'];
25
        $output['sum'] += $input['sum'];
26
27
        foreach ($input['quantiles'] as $idx => $quantile) {
28
            $old = &$output['quantiles'][$idx][1];
29
            $new = $quantile[1];
30
            $old = ($old + $new) / 2;
31
        }
32
    }
33
}
34