DiscussMessage::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 8
dl 0
loc 8
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
 * This file is part of the slince/smartqq package.
4
 *
5
 * (c) Slince <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Slince\SmartQQ\Message\Response;
12
13
use Slince\SmartQQ\Message\Content;
14
15
class DiscussMessage extends Message
16
{
17
    /**
18
     * 接收用户编号,也是QQ号.
19
     *
20
     * @var int
21
     */
22
    protected $toUin;
23
24
    /**
25
     * 讨论组编号.
26
     *
27
     * @var int
28
     */
29
    protected $fromUin;
30
31
    /**
32
     * 讨论组编号,同fromUin
33
     * PS: 对应影响中的did.
34
     *
35
     * @var int
36
     */
37
    protected $discussId;
38
39
    /**
40
     * 发信用户编号,非QQ号.
41
     *
42
     * @var int
43
     */
44
    protected $sendUin;
45
46
    public function __construct($toUin, $fromUin, $discussId, $sendUin, Content $content, $time, $msgId = 0, $msgType = 0)
47
    {
48
        $this->toUin = $toUin;
49
        $this->fromUin = $fromUin;
50
        $this->discussId = $discussId;
51
        $this->sendUin = $sendUin;
52
        parent::__construct($content, $time, $msgId, $msgType);
53
    }
54
55
    /**
56
     * @param int $toUin
57
     */
58
    public function setToUin($toUin)
59
    {
60
        $this->toUin = $toUin;
61
    }
62
63
    /**
64
     * @param int $fromUin
65
     */
66
    public function setFromUin($fromUin)
67
    {
68
        $this->fromUin = $fromUin;
69
    }
70
71
    /**
72
     * @param int $discussId
73
     */
74
    public function setDiscussId($discussId)
75
    {
76
        $this->discussId = $discussId;
77
    }
78
79
    /**
80
     * @param int $sendUin
81
     */
82
    public function setSendUin($sendUin)
83
    {
84
        $this->sendUin = $sendUin;
85
    }
86
87
    /**
88
     * @return int
89
     */
90
    public function getToUin()
91
    {
92
        return $this->toUin;
93
    }
94
95
    /**
96
     * @return int
97
     */
98
    public function getFromUin()
99
    {
100
        return $this->fromUin;
101
    }
102
103
    /**
104
     * @return int
105
     */
106
    public function getDiscussId()
107
    {
108
        return $this->discussId;
109
    }
110
111
    /**
112
     * @return int
113
     */
114
    public function getSendUin()
115
    {
116
        return $this->sendUin;
117
    }
118
}
119