Metric::adjust()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Lamoda\Metric\Common;
4
5
use Lamoda\Metric\Storage\MutableMetricInterface;
6
7
final class Metric implements MutableMetricInterface
8
{
9
    /** @var string */
10
    private $name;
11
    /** @var float */
12
    private $value;
13
    /** @var string[] */
14
    private $tags;
15
16
    /**
17
     * Metric constructor.
18
     *
19
     * @param string   $name
20
     * @param float    $value
21
     * @param string[] $tags
22
     */
23 3
    public function __construct(string $name, float $value, array $tags = [])
24
    {
25 3
        $this->name = $name;
26 3
        $this->value = $value;
27 3
        $this->tags = $tags;
28 3
    }
29
30
    /** {@inheritdoc} */
31 1
    public function getName(): string
32
    {
33 1
        return $this->name;
34
    }
35
36
    /** {@inheritdoc} */
37 3
    public function resolve(): float
38
    {
39 3
        return $this->value;
40
    }
41
42
    /** {@inheritdoc} */
43 1
    public function getTags(): array
44
    {
45 1
        return $this->tags;
46
    }
47
48
    /** {@inheritdoc} */
49 1
    public function adjust(float $delta): void
50
    {
51 1
        $this->value += $delta;
52 1
    }
53
54
    /** {@inheritdoc} */
55 1
    public function setValue(float $value): void
56
    {
57 1
        $this->value = $value;
58 1
    }
59
}
60