Message::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 24
rs 9.9
cc 3
nc 4
nop 11

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 Rezahmady\Smsir\Responses;
4
5
class Message
6
{
7
    /**
8
     * @var int
9
     */
10
    public $id;
11
12
    /**
13
     * @var string
14
     */
15
    public $lineNumber;
16
17
    /**
18
     * @var string
19
     */
20
    public $SMSMessageBody;
21
22
    /**
23
     * @var string
24
     */
25
    public $mobileNumber;
26
27
    /**
28
     * @var string
29
     */
30
    public $toBeSentAt;
31
32
    /**
33
     * @var string
34
     */
35
    public $nativeDeliveryStatus;
36
37
    /**
38
     * @var string
39
     */
40
    public $typeOfMessage;
41
42
    /**
43
     * @var string
44
     */
45
    public $sendAtLatin;
46
47
    /**
48
     * @var string
49
     */
50
    public $sendAtJalali;
51
52
    /**
53
     * @var bool
54
     */
55
    public $isChecked;
56
57
    /**
58
     * @var bool
59
     */
60
    public $isError;
61
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);
0 ignored issues
show
Documentation Bug introduced by
The property $isChecked was declared of type boolean, but $isChecked === false ? 0 : 1 is of type integer. Maybe add a type cast?

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.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
85
        $this->isError = ($isError === false ? 0 : 1);
0 ignored issues
show
Documentation Bug introduced by
The property $isError was declared of type boolean, but $isError === false ? 0 : 1 is of type integer. Maybe add a type cast?

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.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
86
    }
87
}
88