Conditions | 3 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
62 | public function __construct( |
||
63 | int $id, |
||
64 | string $lineNumber, |
||
65 | string $SMSMessageBody, |
||
66 | string $mobileNumber, |
||
67 | string $typeOfMessage, |
||
68 | string $nativeDeliveryStatus, |
||
69 | string $toBeSentAt, |
||
70 | string $sendAtLatin, |
||
71 | string $sendAtJalali, |
||
72 | bool $isChecked, |
||
73 | bool $isError |
||
74 | ) { |
||
75 | $this->id = $id; |
||
76 | $this->lineNumber = $lineNumber; |
||
77 | $this->mobileNumber = $mobileNumber; |
||
78 | $this->SMSMessageBody = $SMSMessageBody; |
||
79 | $this->typeOfMessage = $typeOfMessage; |
||
80 | $this->nativeDeliveryStatus = $nativeDeliveryStatus; |
||
81 | $this->toBeSentAt = $toBeSentAt; |
||
82 | $this->sendAtJalali = $sendAtJalali; |
||
83 | $this->sendAtLatin = $sendAtLatin; |
||
84 | $this->isChecked = ($isChecked === false ? 0 : 1); |
||
|
|||
85 | $this->isError = ($isError === false ? 0 : 1); |
||
86 | } |
||
88 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.