AbstractTwitterMedia::initTwitterMedia()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 9.2
c 0
b 0
f 0
cc 1
eloc 19
nc 1
nop 9
crap 1

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 Twitter\Object;
4
5
use Twitter\TwitterEntity;
6
7
abstract class AbstractTwitterMedia extends TwitterEntity
8
{
9
    /**
10
     * @var int
11
     */
12
    private $id;
13
14
    /**
15
     * @var string
16
     */
17
    protected $mediaUrl;
18
19
    /**
20
     * @var string
21
     */
22
    protected $mediaUrlHttps;
23
24
    /**
25
     * @var string
26
     */
27
    protected $url;
28
29
    /**
30
     * @var string
31
     */
32
    protected $displayUrl;
33
34
    /**
35
     * @var string
36
     */
37
    protected $expandedUrl;
38
39
    /**
40
     * @var TwitterMediaSize[]
41
     */
42
    protected $sizes;
43
44
    /**
45
     * @var string
46
     */
47
    protected $type;
48
49
    /**
50
     * Init.
51
     *
52
     * @param int                  $id
53
     * @param string               $mediaUrl
54
     * @param string               $mediaUrlHttps
55
     * @param string               $url
56
     * @param string               $displayUrl
57
     * @param string               $expandedUrl
58
     * @param TwitterMediaSize[]   $sizes
59
     * @param string               $type
60
     * @param TwitterEntityIndices $indices
61
     */
62 18
    protected function initTwitterMedia(
63
        $id = null,
64
        $mediaUrl = null,
65
        $mediaUrlHttps = null,
66
        $url = null,
67
        $displayUrl = null,
68
        $expandedUrl = null,
69
        array $sizes = [],
70
        $type = null,
71
        TwitterEntityIndices $indices = null
72
    ) {
73 18
        $this->initTwitterEntity($indices);
74
75 18
        $this->displayUrl = $displayUrl;
76 18
        $this->expandedUrl = $expandedUrl;
77 18
        $this->id = $id;
78 18
        $this->mediaUrl = $mediaUrl;
79 18
        $this->mediaUrlHttps = $mediaUrlHttps;
80 18
        $this->sizes = $sizes;
81 18
        $this->type = $type;
82 18
        $this->url = $url;
83 18
    }
84
85
    /**
86
     * @return string
87
     */
88 18
    public function getDisplayUrl()
89
    {
90 18
        return $this->displayUrl;
91
    }
92
93
    /**
94
     * @return string
95
     */
96 18
    public function getExpandedUrl()
97
    {
98 18
        return $this->expandedUrl;
99
    }
100
101
    /**
102
     * @return int
103
     */
104 18
    public function getId()
105
    {
106 18
        return $this->id;
107
    }
108
109
    /**
110
     * @return string
111
     */
112 18
    public function getMediaUrl()
113
    {
114 18
        return $this->mediaUrl;
115
    }
116
117
    /**
118
     * @return string
119
     */
120 18
    public function getMediaUrlHttps()
121
    {
122 18
        return $this->mediaUrlHttps;
123
    }
124
125
    /**
126
     * @return TwitterMediaSize[]
127
     */
128 18
    public function getSizes()
129
    {
130 18
        return $this->sizes;
131
    }
132
133
    /**
134
     * @return string
135
     */
136 18
    public function getType()
137
    {
138 18
        return $this->type;
139
    }
140
141
    /**
142
     * @return string
143
     */
144 18
    public function getUrl()
145
    {
146 18
        return $this->url;
147
    }
148
}
149