Counter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A inc() 0 3 2
1
<?php
2
/**
3
 * Metrics type "counter"
4
 * User: moyo
5
 * Date: 2018/5/18
6
 * Time: 10:26 AM
7
 */
8
9
namespace Carno\Monitor\Metrics;
10
11
use Carno\Monitor\Chips\Metrical\Labeled;
12
use Carno\Monitor\Chips\Metrical\Named;
13
use Carno\Monitor\Chips\Metrical\Reporting;
14
use Carno\Monitor\Chips\Metrical\VExporter;
15
use Carno\Monitor\Contracts\HMRegistry;
16
use Carno\Monitor\Contracts\RAWMetrics;
17
use Carno\Monitor\Contracts\Telemetry;
18
19
class Counter implements RAWMetrics, HMRegistry, Telemetry
20
{
21
    use Named, Labeled, VExporter, Reporting;
22
23
    /**
24
     * @var float
25
     */
26
    private $value = 0;
27
28
    /**
29
     * @param float $v
30
     * @return float
31
     */
32
    public function inc(float $v = 1) : float
33
    {
34
        return $v > 0 ? $this->value += $v : $this->value;
35
    }
36
}
37