Passed
Push — master ( 8cd1cf...370b72 )
by Jasper
03:04
created

Error::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 8
dl 0
loc 18
ccs 9
cts 9
cp 1
crap 1
rs 10
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 Swis\JsonApi\Client;
4
5
use Swis\JsonApi\Client\Traits\HasLinks;
6
use Swis\JsonApi\Client\Traits\HasMeta;
7
8
class Error
9
{
10
    use HasLinks, HasMeta;
11
12
    /**
13
     * @var string|null
14
     */
15
    protected $id;
16
17
    /**
18
     * @var string|null
19
     */
20
    protected $status;
21
22
    /**
23
     * @var string|null
24
     */
25
    protected $code;
26
27
    /**
28
     * @var string|null
29
     */
30
    protected $title;
31
32
    /**
33
     * @var string|null
34
     */
35
    protected $detail;
36
37
    /**
38
     * @var \Swis\JsonApi\Client\ErrorSource|null
39
     */
40
    protected $source;
41
42
    /**
43
     * @param string|null                           $id
44
     * @param \Swis\JsonApi\Client\Links|null       $links
45
     * @param string|null                           $status
46
     * @param string|null                           $code
47
     * @param string|null                           $title
48
     * @param string|null                           $detail
49
     * @param \Swis\JsonApi\Client\ErrorSource|null $source
50
     * @param \Swis\JsonApi\Client\Meta|null        $meta
51
     */
52 5
    public function __construct(
53
        string $id = null,
54
        Links $links = null,
55
        string $status = null,
56
        string $code = null,
57
        string $title = null,
58
        string $detail = null,
59
        ErrorSource $source = null,
60
        Meta $meta = null
61
    ) {
62 5
        $this->id = $id;
63 5
        $this->links = $links;
64 5
        $this->status = $status;
65 5
        $this->code = $code;
66 5
        $this->title = $title;
67 5
        $this->detail = $detail;
68 5
        $this->source = $source;
69 5
        $this->meta = $meta;
70 5
    }
71
72
    /**
73
     * @return string|null
74
     */
75 5
    public function getId()
76
    {
77 5
        return $this->id;
78
    }
79
80
    /**
81
     * @return string|null
82
     */
83 5
    public function getStatus()
84
    {
85 5
        return $this->status;
86
    }
87
88
    /**
89
     * @return string|null
90
     */
91 5
    public function getCode()
92
    {
93 5
        return $this->code;
94
    }
95
96
    /**
97
     * @return string|null
98
     */
99 5
    public function getTitle()
100
    {
101 5
        return $this->title;
102
    }
103
104
    /**
105
     * @return string|null
106
     */
107 5
    public function getDetail()
108
    {
109 5
        return $this->detail;
110
    }
111
112
    /**
113
     * @return \Swis\JsonApi\Client\ErrorSource|null
114
     */
115 5
    public function getSource()
116
    {
117 5
        return $this->source;
118
    }
119
}
120