Completed
Push — feature/html-code-handler ( 96dc8d...cc2e65 )
by Arnaud
02:53
created

UrlInfo::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 10
dl 0
loc 22
ccs 11
cts 11
cp 1
crap 1
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 2
    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 2
        $this->scheme = $scheme;
31 2
        $this->host = $host;
32 2
        $this->port = $port;
33 2
        $this->user = $user;
34 2
        $this->pass = $pass;
35 2
        $this->path = $path;
36 2
        $this->query = $query;
37 2
        $this->fragment = $fragment;
38 2
        $this->routeName = $routeName;
39 2
        $this->extra = $extra;
40 2
    }
41
42
    /**
43
     * @return string
44
     */
45 1
    public function getScheme(): string
46
    {
47 1
        return $this->scheme;
48
    }
49
50
    /**
51
     * @return string
52
     */
53 1
    public function getHost(): string
54
    {
55 1
        return $this->host;
56
    }
57
58
    /**
59
     * @return int
60
     */
61 1
    public function getPort(): int
62
    {
63 1
        return $this->port;
64
    }
65
66
    /**
67
     * @return string
68
     */
69 1
    public function getUser(): string
70
    {
71 1
        return $this->user;
72
    }
73
74
    /**
75
     * @return string
76
     */
77 1
    public function getPass(): string
78
    {
79 1
        return $this->pass;
80
    }
81
82
    /**
83
     * @return string
84
     */
85 1
    public function getPath(): string
86
    {
87 1
        return $this->path;
88
    }
89
90
    /**
91
     * @return string
92
     */
93 1
    public function getQuery(): string
94
    {
95 1
        return $this->query;
96
    }
97
98
    /**
99
     * @return string
100
     */
101 1
    public function getFragment(): string
102
    {
103 1
        return $this->fragment;
104
    }
105
106
    /**
107
     * @return string
108
     */
109 2
    public function getRouteName(): string
110
    {
111 2
        return $this->routeName;
112
    }
113
114
    /**
115
     * @return array
116
     */
117 1
    public function getExtra(): array
118
    {
119 1
        return $this->extra;
120
    }
121
}
122