Metric   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 23
c 1
b 0
f 0
dl 0
loc 92
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A value() 0 3 1
A stdDev() 0 3 1
A count() 0 3 1
A max() 0 3 1
A min() 0 3 1
A __construct() 0 20 1
1
<?php
2
3
/**
4
 * This file is part of slick/telemetry package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Slick\Telemetry\Model;
13
14
use Slick\Telemetry\Trackable;
15
16
/**
17
 * Metric
18
 *
19
 * @package Slick\Telemetry\Model
20
 */
21
final class Metric implements Trackable
22
{
23
    use TrackableMethods;
24
25
    private float $value;
26
    private ?int $count;
27
    private ?float $min;
28
    private ?float $max;
29
    private ?float $stdDev;
30
31
    /**
32
     * Creates a Metric
33
     *
34
     * @param string $message
35
     * @param float $value
36
     * @param int|null $count
37
     * @param float|null $min
38
     * @param float|null $max
39
     * @param float|null $stdDev
40
     * @param iterable|null $context
41
     */
42
    public function __construct(
43
        string $message,
44
        float $value,
45
        ?int $count = null,
46
        ?float $min = null,
47
        ?float $max = null,
48
        ?float $stdDev = null,
49
        ?iterable $context = []
50
    ) {
51
        $this->message = $message;
52
        $this->value = $value;
53
        $this->count = $count;
54
        $this->min = $min;
55
        $this->max = $max;
56
        $this->stdDev = $stdDev;
57
        $this->label = Trackable::LABEL_METRIC;
58
        $this->context = array_merge(
59
            $context,
0 ignored issues
show
Bug introduced by
It seems like $context can also be of type iterable and null; however, parameter $arrays of array_merge() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

59
            /** @scrutinizer ignore-type */ $context,
Loading history...
60
            ['label' => $this->label],
61
            compact('value', 'count', 'min', 'max', 'stdDev')
62
        );
63
    }
64
65
    /**
66
     * value
67
     *
68
     * @return float
69
     */
70
    public function value(): float
71
    {
72
        return $this->value;
73
    }
74
75
    /**
76
     * count
77
     *
78
     * @return int|null
79
     */
80
    public function count(): ?int
81
    {
82
        return $this->count;
83
    }
84
85
    /**
86
     * min
87
     *
88
     * @return float|null
89
     */
90
    public function min(): ?float
91
    {
92
        return $this->min;
93
    }
94
95
    /**
96
     * max
97
     *
98
     * @return float|null
99
     */
100
    public function max(): ?float
101
    {
102
        return $this->max;
103
    }
104
105
    /**
106
     * stdDev
107
     *
108
     * @return float|null
109
     */
110
    public function stdDev(): ?float
111
    {
112
        return $this->stdDev;
113
    }
114
}
115