Test Failed
Push — feature/html-code-handler ( 2b7167...3f6bac )
by Arnaud
02:50
created

UrlInfo::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 10
dl 0
loc 22
rs 9.9332
c 0
b 0
f 0

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 LAG\SmokerBundle\Url;
4
5
class UrlInfo
6
{
7
    protected $scheme = '';
8
    protected $host = '';
9
    protected $port = 80;
10
    protected $user = '';
11
    protected $pass = '';
12
    protected $path = '';
13
    protected $query = '';
14
    protected $fragment = '';
15
    protected $routeName = '';
16
    protected $extra = [];
17
18
    public function __construct(
19
        string $scheme,
20
        string $host,
21
        int $port,
22
        string $path,
23
        string $query,
24
        string $fragment,
25
        string $routeName,
26
        array $extra = [],
27
        string $user = '',
28
        string $pass = ''
29
    ) {
30
        $this->scheme = $scheme;
31
        $this->host = $host;
32
        $this->port = $port;
33
        $this->user = $user;
34
        $this->pass = $pass;
35
        $this->path = $path;
36
        $this->query = $query;
37
        $this->fragment = $fragment;
38
        $this->routeName = $routeName;
39
        $this->extra = $extra;
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getScheme(): string
46
    {
47
        return $this->scheme;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getHost(): string
54
    {
55
        return $this->host;
56
    }
57
58
    /**
59
     * @return int
60
     */
61
    public function getPort(): int
62
    {
63
        return $this->port;
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function getUser(): string
70
    {
71
        return $this->user;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getPass(): string
78
    {
79
        return $this->pass;
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getPath(): string
86
    {
87
        return $this->path;
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function getQuery(): string
94
    {
95
        return $this->query;
96
    }
97
98
    /**
99
     * @return string
100
     */
101
    public function getFragment(): string
102
    {
103
        return $this->fragment;
104
    }
105
106
    /**
107
     * @return string
108
     */
109
    public function getRouteName(): string
110
    {
111
        return $this->routeName;
112
    }
113
114
    /**
115
     * @return array
116
     */
117
    public function getExtra(): array
118
    {
119
        return $this->extra;
120
    }
121
}
122