GroupMessage::__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 GroupMessage 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
     *
34
     * @var int
35
     */
36
    protected $groupCode;
37
38
    /**
39
     * 发信用户编号,非QQ号.
40
     *
41
     * @var int
42
     */
43
    protected $sendUin;
44
45
    public function __construct($toUin, $fromUin, $groupCode, $sendUin, Content $content, $time, $msgId = 0, $msgType = 0)
46
    {
47
        $this->toUin = $toUin;
48
        $this->fromUin = $fromUin;
49
        $this->groupCode = $groupCode;
50
        $this->sendUin = $sendUin;
51
        parent::__construct($content, $time, $msgId, $msgType);
52
    }
53
54
    /**
55
     * @param int $toUin
56
     */
57
    public function setToUin($toUin)
58
    {
59
        $this->toUin = $toUin;
60
    }
61
62
    /**
63
     * @param int $fromUin
64
     */
65
    public function setFromUin($fromUin)
66
    {
67
        $this->fromUin = $fromUin;
68
    }
69
70
    /**
71
     * @param int $groupCode
72
     */
73
    public function setGroupCode($groupCode)
74
    {
75
        $this->groupCode = $groupCode;
76
    }
77
78
    /**
79
     * @param int $sendUin
80
     */
81
    public function setSendUin($sendUin)
82
    {
83
        $this->sendUin = $sendUin;
84
    }
85
86
    /**
87
     * @return int
88
     */
89
    public function getToUin()
90
    {
91
        return $this->toUin;
92
    }
93
94
    /**
95
     * @return int
96
     */
97
    public function getFromUin()
98
    {
99
        return $this->fromUin;
100
    }
101
102
    /**
103
     * @return int
104
     */
105
    public function getGroupCode()
106
    {
107
        return $this->groupCode;
108
    }
109
110
    /**
111
     * @return int
112
     */
113
    public function getSendUin()
114
    {
115
        return $this->sendUin;
116
    }
117
}
118