Histogram::trkHistogram()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 2
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Trunking of "histogram"
4
 * User: moyo
5
 * Date: 2018/5/19
6
 * Time: 1:03 PM
7
 */
8
9
namespace Carno\Monitor\Chips\Trunks;
10
11
trait Histogram
12
{
13
    /**
14
     * @param array $input
15
     * @param array $output
16
     */
17
    protected function trkHistogram(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['buckets'] as $idx => $bucket) {
28
            $output['buckets'][$idx][1] += $bucket[1];
29
        }
30
    }
31
}
32