| Total Complexity | 6 |
| Total Lines | 92 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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, |
||
|
|
|||
| 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 |
||
| 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 |
||
| 113 | } |
||
| 114 | } |
||
| 115 |