FaceDetectionResult::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 9
nc 1
nop 9

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
namespace XSolve\FaceValidatorBundle\Result;
4
5
class FaceDetectionResult
6
{
7
    /**
8
     * @var float
9
     */
10
    private $faceToImageRatio;
11
12
    /**
13
     * @var Rotation
14
     */
15
    private $rotation;
16
17
    /**
18
     * @var Glasses
19
     */
20
    private $glasses;
21
22
    /**
23
     * @var Blur
24
     */
25
    private $blur;
26
27
    /**
28
     * @var Exposure
29
     */
30
    private $exposure;
31
32
    /**
33
     * @var Noise
34
     */
35
    private $noise;
36
37
    /**
38
     * @var Makeup
39
     */
40
    private $makeup;
41
42
    /**
43
     * @var Accessory[]
44
     */
45
    private $accessories;
46
47
    /**
48
     * @var bool
49
     */
50
    private $hairVisible;
51
52
    public function __construct(
53
        float $faceToImageRatio,
54
        Rotation $rotation,
55
        Glasses $glasses,
56
        Blur $blur,
57
        Exposure $exposure,
58
        Noise $noise,
59
        Makeup $makeup,
60
        array $accessories,
61
        bool $hairVisible
62
    ) {
63
        $this->faceToImageRatio = $faceToImageRatio;
64
        $this->rotation = $rotation;
65
        $this->glasses = $glasses;
66
        $this->blur = $blur;
67
        $this->exposure = $exposure;
68
        $this->noise = $noise;
69
        $this->makeup = $makeup;
70
        $this->accessories = $accessories;
71
        $this->hairVisible = $hairVisible;
72
    }
73
74
    public function getFaceToImageRatio(): float
75
    {
76
        return $this->faceToImageRatio;
77
    }
78
79
    public function getRotation(): Rotation
80
    {
81
        return $this->rotation;
82
    }
83
84
    public function getGlasses(): Glasses
85
    {
86
        return $this->glasses;
87
    }
88
89
    public function getBlur(): Blur
90
    {
91
        return $this->blur;
92
    }
93
94
    public function getExposure(): Exposure
95
    {
96
        return $this->exposure;
97
    }
98
99
    public function getNoise(): Noise
100
    {
101
        return $this->noise;
102
    }
103
104
    public function getMakeup(): Makeup
105
    {
106
        return $this->makeup;
107
    }
108
109
    public function getAccessories(): array
110
    {
111
        return $this->accessories;
112
    }
113
114
    public function isHairVisible(): bool
115
    {
116
        return $this->hairVisible;
117
    }
118
}
119