ParcelStatus::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 8
dl 0
loc 18
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 DansMaCulotte\Colissimo\Resources;
4
5
class ParcelStatus
6
{
7
    public $data;
8
9
    public function __construct(
10
        string $skybillNumber,
11
        string $eventCode,
12
        string $eventDate,
13
        string $eventLibelle,
14
        string $eventSite,
15
        string $recipientCity,
16
        string $recipientZipCode,
17
        string $recipientCountryCode
18
    ) {
19
        $this->data['id'] = $skybillNumber;
20
        $this->data['code'] = $eventCode;
21
        $this->data['date'] = $eventDate;
22
        $this->data['status'] = $eventLibelle;
23
        $this->data['site'] = $eventSite;
24
        $this->data['city'] = $recipientCity;
25
        $this->data['zipCode'] = $recipientZipCode;
26
        $this->data['countryCode'] = $recipientCountryCode;
27
    }
28
}
29