UrlInfo::__construct()   A
last analyzed

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 1
    public function getScheme(): string
43
    {
44 1
        return $this->scheme;
45
    }
46
47 1
    public function getHost(): string
48
    {
49 1
        return $this->host;
50
    }
51
52 1
    public function getPort(): int
53
    {
54 1
        return $this->port;
55
    }
56
57 1
    public function getUser(): string
58
    {
59 1
        return $this->user;
60
    }
61
62 1
    public function getPass(): string
63
    {
64 1
        return $this->pass;
65
    }
66
67 1
    public function getPath(): string
68
    {
69 1
        return $this->path;
70
    }
71
72 1
    public function getQuery(): string
73
    {
74 1
        return $this->query;
75
    }
76
77 1
    public function getFragment(): string
78
    {
79 1
        return $this->fragment;
80
    }
81
82 2
    public function getRouteName(): string
83
    {
84 2
        return $this->routeName;
85
    }
86
87 1
    public function getExtra(): array
88
    {
89 1
        return $this->extra;
90
    }
91
}
92