Face::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
c 0
b 0
f 0
nc 1
nop 9
dl 0
loc 11
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 AhmadMayahi\Vision\Data;
6
7
use AhmadMayahi\Vision\Enums\Likelihood;
8
use AhmadMayahi\Vision\Support\AbstractConditionalLikelihood;
9
10
/**
11
 * @method bool isAngry($likelihood = Likelihood::VERY_LIKELY)
12
 * @method bool isJoyful($likelihood = Likelihood::VERY_LIKELY)
13
 * @method bool isSurprised($likelihood = Likelihood::VERY_LIKELY)
14
 * @method bool isBlurred($likelihood = Likelihood::VERY_LIKELY)
15
 * @method bool isHeadwear($likelihood = Likelihood::VERY_LIKELY)
16
 * @method bool isUnderExposed($likelihood = Likelihood::VERY_LIKELY)
17
 */
18
final class Face extends AbstractConditionalLikelihood
19
{
20
    public function __construct(
21
        public string $anger,
22
        public string $joy,
23
        public string $surprise,
24
        public string $blurred,
25
        public string $headwear,
26
        public string $underExposed,
27
        public array  $bounds,
28
        public float  $detectionConfidence,
29
        public float  $landmarking,
30
    ) {
31
    }
32
33
    protected function conditionals(): array
34
    {
35
        return [
36
            'angry' => 'anger',
37
            'joyful' => 'joy',
38
            'surprised' => 'surprise',
39
        ];
40
    }
41
}
42