Metric::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 9
dl 0
loc 11
ccs 2
cts 2
cp 1
crap 1
rs 10

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace ArangoClient\Prometheus;
6
7
class Metric
8
{
9
    /**
10
     * @param string $name
11
     * @param null|string $type
12
     * @param string|null $help
13
     * @param int|float|null $count
14
     * @param int|float|null $sum
15
     * @param int|float|null $value
16
     * @param array<array-key, Bucket>|null $buckets
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array-key, Bucket>|null at position 2 could not be parsed: Unknown type name 'array-key' at position 2 in array<array-key, Bucket>|null.
Loading history...
17
     * @param array<string, float|int|string>|null $labels
18
     */
19 4
    public function __construct(
20
        public string $name,
21
        public null|string $type = null,
22
        public null|string $help = null,
23
        public int|float|null $count = null,
24
        public int|float|null $sum = null,
25
        public int|float|null $value = null,
26
        public ?array $buckets = [],
27
        public ?array $labels = [],
28 4
        public null|int $timestamp = null,
29
    ) {}
30
}
31