Counter::inc()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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