Passed
Push — master ( 248c35...f550ad )
by Reyo
04:07
created

Project   F

Complexity

Total Complexity 68

Size/Duplication

Total Lines 609
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 68
eloc 137
c 1
b 0
f 0
dl 0
loc 609
ccs 0
cts 305
cp 0
rs 2.96

68 Methods

Rating   Name   Duplication   Size   Complexity  
A setActive() 0 5 1
A setInvoiceReference() 0 5 1
A getBudgetNotificationHasBeenSent() 0 3 1
A getExternalName() 0 3 1
A setUnspecified() 0 5 1
A getExternalUrl() 0 3 1
A getInvoiceReference() 0 3 1
A setColor() 0 5 1
A getEndDate() 0 3 1
A setBudgetRate() 0 5 1
A setClientId() 0 5 1
A setId() 0 5 1
A setStartDate() 0 5 1
A setCode() 0 5 1
A getProjectUsers() 0 3 1
A setInvoiceDate() 0 5 1
A setInvoiceMethod() 0 5 1
A setTagNames() 0 5 1
A getProjectSubscription() 0 3 1
A getVisibleOnSchedule() 0 3 1
A setName() 0 5 1
A setEndDate() 0 5 1
A getBudgetRate() 0 3 1
A getBudgetHours() 0 3 1
A setExternalUrl() 0 5 1
A setProjectTasks() 0 5 1
A setRemainingBudgetHours() 0 5 1
A getColor() 0 3 1
A getId() 0 3 1
A setTagIds() 0 5 1
A setBudgetNotificationPercentage() 0 5 1
A getUnspecified() 0 3 1
A getActive() 0 3 1
A getRate() 0 3 1
A getBudgetNotificationPercentage() 0 3 1
A getInvoiceDate() 0 3 1
A getInvoiceId() 0 3 1
A setHourlyRate() 0 5 1
A setInvoiceStatus() 0 5 1
A setNotes() 0 5 1
A getBudgetMethod() 0 3 1
A getProjectTasks() 0 3 1
A getInvoiceMethod() 0 3 1
A setProjectUsers() 0 5 1
A setExternalName() 0 5 1
A setVisibleOnSchedule() 0 5 1
A getTagIds() 0 3 1
A getNotes() 0 3 1
A getName() 0 3 1
A getCode() 0 3 1
A setInvoiceId() 0 5 1
A getClientId() 0 3 1
A setInvoiceInInstallments() 0 5 1
A getCustomerId() 0 3 1
A getInvoiceInInstallments() 0 3 1
A setProjectSubscription() 0 5 1
A getRemainingBudgetHours() 0 3 1
A setCustomerId() 0 5 1
A getStartDate() 0 3 1
A getInvoiceStatus() 0 3 1
A getCustomerName() 0 3 1
A setCustomerName() 0 5 1
A setBudgetNotificationHasBeenSent() 0 5 1
A setBudgetMethod() 0 5 1
A setBudgetHours() 0 5 1
A setRate() 0 5 1
A getHourlyRate() 0 3 1
A getTagNames() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like Project often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Project, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the timechimp bundle package.
7
 * (c) Connect Holland.
8
 */
9
10
namespace ConnectHolland\TimechimpBundle\Api\Client\Model;
11
12
class Project
13
{
14
    /**
15
     * @var float
16
     */
17
    protected $remainingBudgetHours;
18
    /**
19
     * @var int[]
20
     */
21
    protected $tagIds;
22
    /**
23
     * @var string[]
24
     */
25
    protected $tagNames;
26
    /**
27
     * @var bool
28
     */
29
    protected $unspecified;
30
    /**
31
     * @var \DateTime
32
     */
33
    protected $invoiceDate;
34
    /**
35
     * @var bool
36
     */
37
    protected $invoiceInInstallments;
38
    /**
39
     * @var float
40
     */
41
    protected $budgetNotificationPercentage;
42
    /**
43
     * @var bool
44
     */
45
    protected $budgetNotificationHasBeenSent;
46
    /**
47
     * @var string
48
     */
49
    protected $clientId;
50
    /**
51
     * 0 = Open, 1 = PendingApproval, 2 = Approved, 3 = Invoiced, 4 = WrittenOff, -1 = Rejected.
52
     *
53
     * @var int
54
     */
55
    protected $invoiceStatus;
56
    /**
57
     * @var int
58
     */
59
    protected $invoiceId;
60
    /**
61
     * @var string
62
     */
63
    protected $color;
64
    /**
65
     * @var bool
66
     */
67
    protected $visibleOnSchedule;
68
    /**
69
     * @var string
70
     */
71
    protected $externalUrl;
72
    /**
73
     * @var string
74
     */
75
    protected $externalName;
76
    /**
77
     * @var string
78
     */
79
    protected $invoiceReference;
80
    /**
81
     * @var ProjectTask[]
82
     */
83
    protected $projectTasks;
84
    /**
85
     * @var ProjectUser[]
86
     */
87
    protected $projectUsers;
88
    /**
89
     * @var int
90
     */
91
    protected $id;
92
    /**
93
     * @var bool
94
     */
95
    protected $active;
96
    /**
97
     * Customer id is required.
98
     *
99
     * @var int
100
     */
101
    protected $customerId;
102
    /**
103
     * @var string
104
     */
105
    protected $customerName;
106
    /**
107
     * Customer name is required.
108
     *
109
     * @var string
110
     */
111
    protected $name;
112
    /**
113
     * @var string
114
     */
115
    protected $code;
116
    /**
117
     * @var string
118
     */
119
    protected $notes;
120
    /**
121
     * 1 = NoInvoicing, 2 = TaskHourlyRate, 3 = UserHourlyRate, 4 = ProjectHourlyRate, 5 = CustomerHourlyRate, 6 = ProjectRate, 7 = TaskRate, 8 = MilestoneRate, 9 = Subscription.
122
     *
123
     * @var int
124
     */
125
    protected $invoiceMethod;
126
    /**
127
     * @var float
128
     */
129
    protected $hourlyRate;
130
    /**
131
     * @var float
132
     */
133
    protected $rate;
134
    /**
135
     * 1 = NoBudget, 2 = TotalHours, 3 = TaskHours, 4 = UserHours, 5 = TotalRate, 6 = TaskRate, 7 = Invoiced.
136
     *
137
     * @var int
138
     */
139
    protected $budgetMethod;
140
    /**
141
     * @var float
142
     */
143
    protected $budgetRate;
144
    /**
145
     * @var float
146
     */
147
    protected $budgetHours;
148
    /**
149
     * @var \DateTime
150
     */
151
    protected $startDate;
152
    /**
153
     * @var \DateTime
154
     */
155
    protected $endDate;
156
    /**
157
     * @var ProjectSubscription
158
     */
159
    protected $projectSubscription;
160
161
    public function getRemainingBudgetHours(): float
162
    {
163
        return $this->remainingBudgetHours;
164
    }
165
166
    public function setRemainingBudgetHours(float $remainingBudgetHours): self
167
    {
168
        $this->remainingBudgetHours = $remainingBudgetHours;
169
170
        return $this;
171
    }
172
173
    /**
174
     * @return int[]
175
     */
176
    public function getTagIds(): array
177
    {
178
        return $this->tagIds;
179
    }
180
181
    /**
182
     * @param int[] $tagIds
183
     */
184
    public function setTagIds(array $tagIds): self
185
    {
186
        $this->tagIds = $tagIds;
187
188
        return $this;
189
    }
190
191
    /**
192
     * @return string[]
193
     */
194
    public function getTagNames(): array
195
    {
196
        return $this->tagNames;
197
    }
198
199
    /**
200
     * @param string[] $tagNames
201
     */
202
    public function setTagNames(array $tagNames): self
203
    {
204
        $this->tagNames = $tagNames;
205
206
        return $this;
207
    }
208
209
    public function getUnspecified(): bool
210
    {
211
        return $this->unspecified;
212
    }
213
214
    public function setUnspecified(bool $unspecified): self
215
    {
216
        $this->unspecified = $unspecified;
217
218
        return $this;
219
    }
220
221
    public function getInvoiceDate(): \DateTime
222
    {
223
        return $this->invoiceDate;
224
    }
225
226
    public function setInvoiceDate(\DateTime $invoiceDate): self
227
    {
228
        $this->invoiceDate = $invoiceDate;
229
230
        return $this;
231
    }
232
233
    public function getInvoiceInInstallments(): bool
234
    {
235
        return $this->invoiceInInstallments;
236
    }
237
238
    public function setInvoiceInInstallments(bool $invoiceInInstallments): self
239
    {
240
        $this->invoiceInInstallments = $invoiceInInstallments;
241
242
        return $this;
243
    }
244
245
    public function getBudgetNotificationPercentage(): float
246
    {
247
        return $this->budgetNotificationPercentage;
248
    }
249
250
    public function setBudgetNotificationPercentage(float $budgetNotificationPercentage): self
251
    {
252
        $this->budgetNotificationPercentage = $budgetNotificationPercentage;
253
254
        return $this;
255
    }
256
257
    public function getBudgetNotificationHasBeenSent(): bool
258
    {
259
        return $this->budgetNotificationHasBeenSent;
260
    }
261
262
    public function setBudgetNotificationHasBeenSent(bool $budgetNotificationHasBeenSent): self
263
    {
264
        $this->budgetNotificationHasBeenSent = $budgetNotificationHasBeenSent;
265
266
        return $this;
267
    }
268
269
    public function getClientId(): string
270
    {
271
        return $this->clientId;
272
    }
273
274
    public function setClientId(string $clientId): self
275
    {
276
        $this->clientId = $clientId;
277
278
        return $this;
279
    }
280
281
    /**
282
     * 0 = Open, 1 = PendingApproval, 2 = Approved, 3 = Invoiced, 4 = WrittenOff, -1 = Rejected.
283
     */
284
    public function getInvoiceStatus(): int
285
    {
286
        return $this->invoiceStatus;
287
    }
288
289
    /**
290
     * 0 = Open, 1 = PendingApproval, 2 = Approved, 3 = Invoiced, 4 = WrittenOff, -1 = Rejected.
291
     */
292
    public function setInvoiceStatus(int $invoiceStatus): self
293
    {
294
        $this->invoiceStatus = $invoiceStatus;
295
296
        return $this;
297
    }
298
299
    public function getInvoiceId(): int
300
    {
301
        return $this->invoiceId;
302
    }
303
304
    public function setInvoiceId(int $invoiceId): self
305
    {
306
        $this->invoiceId = $invoiceId;
307
308
        return $this;
309
    }
310
311
    public function getColor(): string
312
    {
313
        return $this->color;
314
    }
315
316
    public function setColor(string $color): self
317
    {
318
        $this->color = $color;
319
320
        return $this;
321
    }
322
323
    public function getVisibleOnSchedule(): bool
324
    {
325
        return $this->visibleOnSchedule;
326
    }
327
328
    public function setVisibleOnSchedule(bool $visibleOnSchedule): self
329
    {
330
        $this->visibleOnSchedule = $visibleOnSchedule;
331
332
        return $this;
333
    }
334
335
    public function getExternalUrl(): string
336
    {
337
        return $this->externalUrl;
338
    }
339
340
    public function setExternalUrl(string $externalUrl): self
341
    {
342
        $this->externalUrl = $externalUrl;
343
344
        return $this;
345
    }
346
347
    public function getExternalName(): string
348
    {
349
        return $this->externalName;
350
    }
351
352
    public function setExternalName(string $externalName): self
353
    {
354
        $this->externalName = $externalName;
355
356
        return $this;
357
    }
358
359
    public function getInvoiceReference(): string
360
    {
361
        return $this->invoiceReference;
362
    }
363
364
    public function setInvoiceReference(string $invoiceReference): self
365
    {
366
        $this->invoiceReference = $invoiceReference;
367
368
        return $this;
369
    }
370
371
    /**
372
     * @return ProjectTask[]
373
     */
374
    public function getProjectTasks(): array
375
    {
376
        return $this->projectTasks;
377
    }
378
379
    /**
380
     * @param ProjectTask[] $projectTasks
381
     */
382
    public function setProjectTasks(array $projectTasks): self
383
    {
384
        $this->projectTasks = $projectTasks;
385
386
        return $this;
387
    }
388
389
    /**
390
     * @return ProjectUser[]
391
     */
392
    public function getProjectUsers(): array
393
    {
394
        return $this->projectUsers;
395
    }
396
397
    /**
398
     * @param ProjectUser[] $projectUsers
399
     */
400
    public function setProjectUsers(array $projectUsers): self
401
    {
402
        $this->projectUsers = $projectUsers;
403
404
        return $this;
405
    }
406
407
    public function getId(): int
408
    {
409
        return $this->id;
410
    }
411
412
    public function setId(int $id): self
413
    {
414
        $this->id = $id;
415
416
        return $this;
417
    }
418
419
    public function getActive(): bool
420
    {
421
        return $this->active;
422
    }
423
424
    public function setActive(bool $active): self
425
    {
426
        $this->active = $active;
427
428
        return $this;
429
    }
430
431
    /**
432
     * Customer id is required.
433
     */
434
    public function getCustomerId(): int
435
    {
436
        return $this->customerId;
437
    }
438
439
    /**
440
     * Customer id is required.
441
     */
442
    public function setCustomerId(int $customerId): self
443
    {
444
        $this->customerId = $customerId;
445
446
        return $this;
447
    }
448
449
    public function getCustomerName(): string
450
    {
451
        return $this->customerName;
452
    }
453
454
    public function setCustomerName(string $customerName): self
455
    {
456
        $this->customerName = $customerName;
457
458
        return $this;
459
    }
460
461
    /**
462
     * Customer name is required.
463
     */
464
    public function getName(): string
465
    {
466
        return $this->name;
467
    }
468
469
    /**
470
     * Customer name is required.
471
     */
472
    public function setName(string $name): self
473
    {
474
        $this->name = $name;
475
476
        return $this;
477
    }
478
479
    public function getCode(): string
480
    {
481
        return $this->code;
482
    }
483
484
    public function setCode(string $code): self
485
    {
486
        $this->code = $code;
487
488
        return $this;
489
    }
490
491
    public function getNotes(): string
492
    {
493
        return $this->notes;
494
    }
495
496
    public function setNotes(string $notes): self
497
    {
498
        $this->notes = $notes;
499
500
        return $this;
501
    }
502
503
    /**
504
     * 1 = NoInvoicing, 2 = TaskHourlyRate, 3 = UserHourlyRate, 4 = ProjectHourlyRate, 5 = CustomerHourlyRate, 6 = ProjectRate, 7 = TaskRate, 8 = MilestoneRate, 9 = Subscription.
505
     */
506
    public function getInvoiceMethod(): int
507
    {
508
        return $this->invoiceMethod;
509
    }
510
511
    /**
512
     * 1 = NoInvoicing, 2 = TaskHourlyRate, 3 = UserHourlyRate, 4 = ProjectHourlyRate, 5 = CustomerHourlyRate, 6 = ProjectRate, 7 = TaskRate, 8 = MilestoneRate, 9 = Subscription.
513
     */
514
    public function setInvoiceMethod(int $invoiceMethod): self
515
    {
516
        $this->invoiceMethod = $invoiceMethod;
517
518
        return $this;
519
    }
520
521
    public function getHourlyRate(): float
522
    {
523
        return $this->hourlyRate;
524
    }
525
526
    public function setHourlyRate(float $hourlyRate): self
527
    {
528
        $this->hourlyRate = $hourlyRate;
529
530
        return $this;
531
    }
532
533
    public function getRate(): float
534
    {
535
        return $this->rate;
536
    }
537
538
    public function setRate(float $rate): self
539
    {
540
        $this->rate = $rate;
541
542
        return $this;
543
    }
544
545
    /**
546
     * 1 = NoBudget, 2 = TotalHours, 3 = TaskHours, 4 = UserHours, 5 = TotalRate, 6 = TaskRate, 7 = Invoiced.
547
     */
548
    public function getBudgetMethod(): int
549
    {
550
        return $this->budgetMethod;
551
    }
552
553
    /**
554
     * 1 = NoBudget, 2 = TotalHours, 3 = TaskHours, 4 = UserHours, 5 = TotalRate, 6 = TaskRate, 7 = Invoiced.
555
     */
556
    public function setBudgetMethod(int $budgetMethod): self
557
    {
558
        $this->budgetMethod = $budgetMethod;
559
560
        return $this;
561
    }
562
563
    public function getBudgetRate(): float
564
    {
565
        return $this->budgetRate;
566
    }
567
568
    public function setBudgetRate(float $budgetRate): self
569
    {
570
        $this->budgetRate = $budgetRate;
571
572
        return $this;
573
    }
574
575
    public function getBudgetHours(): float
576
    {
577
        return $this->budgetHours;
578
    }
579
580
    public function setBudgetHours(float $budgetHours): self
581
    {
582
        $this->budgetHours = $budgetHours;
583
584
        return $this;
585
    }
586
587
    public function getStartDate(): \DateTime
588
    {
589
        return $this->startDate;
590
    }
591
592
    public function setStartDate(\DateTime $startDate): self
593
    {
594
        $this->startDate = $startDate;
595
596
        return $this;
597
    }
598
599
    public function getEndDate(): \DateTime
600
    {
601
        return $this->endDate;
602
    }
603
604
    public function setEndDate(\DateTime $endDate): self
605
    {
606
        $this->endDate = $endDate;
607
608
        return $this;
609
    }
610
611
    public function getProjectSubscription(): ProjectSubscription
612
    {
613
        return $this->projectSubscription;
614
    }
615
616
    public function setProjectSubscription(ProjectSubscription $projectSubscription): self
617
    {
618
        $this->projectSubscription = $projectSubscription;
619
620
        return $this;
621
    }
622
}
623