Metric   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 12
dl 0
loc 51
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 3 1
A getName() 0 3 1
A adjust() 0 3 1
A getTags() 0 3 1
A resolve() 0 3 1
A __construct() 0 5 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