SubscriptionPlanObject   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 205
Duplicated Lines 4.39 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 14
c 1
b 0
f 0
lcom 0
cbo 0
dl 9
loc 205
ccs 0
cts 57
cp 0
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getArticleNumber() 0 4 1
A setArticleNumber() 0 6 1
A getQuantity() 0 4 1
A setQuantity() 0 6 1
A getTitle() 0 4 1
A setTitle() 0 6 1
A getDescription() 0 4 1
A setDescription() 0 6 1
A getUnitPrice() 0 4 1
A setUnitPrice() 0 6 1
A getVatPercent() 0 4 1
A setVatPercent() 9 9 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Speicher210\Fastbill\Api\Model;
4
5
use JMS\Serializer\Annotation as JMS;
6
7
/**
8
 * Subscription plan object data.
9
 */
10
class SubscriptionPlanObject
11
{
12
    /**
13
     * The subscription plan article number.
14
     *
15
     * @var string
16
     *
17
     * @JMS\Type("string")
18
     * @JMS\SerializedName("ARTICLE_NUMBER")
19
     */
20
    protected $articleNumber;
21
22
    /**
23
     * The subscription plan quantity.
24
     *
25
     * @var integer
26
     *
27
     * @JMS\Type("integer")
28
     * @JMS\SerializedName("QUANTITY")
29
     */
30
    protected $quantity;
31
32
    /**
33
     * The subscription plan title.
34
     *
35
     * @var string
36
     *
37
     * @JMS\Type("string")
38
     * @JMS\SerializedName("TITLE")
39
     */
40
    protected $title;
41
42
    /**
43
     * The subscription plan description.
44
     *
45
     * @var string
46
     *
47
     * @JMS\Type("string")
48
     * @JMS\SerializedName("DESCRIPTION")
49
     */
50
    protected $description;
51
52
    /**
53
     * The subscription plan unit price.
54
     *
55
     * @var float
56
     *
57
     * @JMS\Type("string")
58
     * @JMS\SerializedName("UNIT_PRICE")
59
     */
60
    protected $unitPrice;
61
62
63
    /**
64
     * The subscription plan vat percent.
65
     *
66
     * @var string
67
     *
68
     * @JMS\Type("string")
69
     * @JMS\SerializedName("VAT_PERCENT")
70
     */
71
    protected $vatPercent;
72
73
    /**
74
     * Get the article number.
75
     *
76
     * @return integer
77
     */
78
    public function getArticleNumber()
79
    {
80
        return $this->articleNumber;
81
    }
82
83
    /**
84
     * Set the article number.
85
     *
86
     * @param string $articleNumber
87
     * @return SubscriptionPlanObject
88
     */
89
    public function setArticleNumber($articleNumber)
90
    {
91
        $this->articleNumber = $articleNumber;
92
93
        return $this;
94
    }
95
96
    /**
97
     * Get the quantity.
98
     *
99
     * @return integer
100
     */
101
    public function getQuantity()
102
    {
103
        return $this->quantity;
104
    }
105
106
    /**
107
     * Set the quantity.
108
     *
109
     * @param integer $quantity
110
     * @return SubscriptionPlanObject
111
     */
112
    public function setQuantity($quantity)
113
    {
114
        $this->quantity = $quantity;
115
116
        return $this;
117
    }
118
119
    /**
120
     * Get the title.
121
     *
122
     * @return string
123
     */
124
    public function getTitle()
125
    {
126
        return $this->title;
127
    }
128
129
    /**
130
     * Set the title.
131
     *
132
     * @param string $title The title.
133
     * @return SubscriptionPlanObject
134
     */
135
    public function setTitle($title)
136
    {
137
        $this->title = $title;
138
139
        return $this;
140
    }
141
142
    /**
143
     * Get the description.
144
     *
145
     * @return string
146
     */
147
    public function getDescription()
148
    {
149
        return $this->description;
150
    }
151
152
    /**
153
     * Set the description.
154
     *
155
     * @param string $description
156
     * @return SubscriptionPlanObject
157
     */
158
    public function setDescription($description)
159
    {
160
        $this->description = $description;
161
162
        return $this;
163
    }
164
165
    /**
166
     * Get the unit price.
167
     *
168
     * @return string
169
     */
170
    public function getUnitPrice()
171
    {
172
        return $this->unitPrice;
173
    }
174
175
    /**
176
     * Set the unit price.
177
     *
178
     * @param float $unitPrice The price
179
     * @return SubscriptionPlanObject
180
     */
181
    public function setUnitPrice($unitPrice)
182
    {
183
        $this->unitPrice = $unitPrice;
184
185
        return $this;
186
    }
187
188
    /**
189
     * Get the VAT percent.
190
     *
191
     * @return string
192
     */
193
    public function getVatPercent()
194
    {
195
        return $this->vatPercent;
196
    }
197
198
    /**
199
     * Set the VAT percent.
200
     *
201
     * @param string $vatPercent
202
     * @return SubscriptionPlanObject
203
     * @throws \InvalidArgumentException If the VAT is not between 0 - 100.
204
     */
205 View Code Duplication
    public function setVatPercent($vatPercent)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
206
    {
207
        if ($vatPercent < 0 || $vatPercent > 100) {
208
            throw new \InvalidArgumentException('VAT must be between 0 - 100');
209
        }
210
        $this->vatPercent = $vatPercent;
211
212
        return $this;
213
    }
214
}
215