ImportMsgListParameter   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 75
ccs 0
cts 27
cp 0
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setMsgBody() 0 11 2
A setRandom() 0 5 1
A setFromAccount() 0 5 1
A transformToArray() 0 3 1
A setSendTime() 0 5 1
1
<?php
2
3
namespace EasyIM\TencentIM\Group\Parameter\Import;
4
5
use EasyIM\Kernel\Contracts\MessageInterface;
6
use EasyIM\Kernel\Parameter;
7
8
/**
9
 * Class ImportMsgListParameter
10
 *
11
 * @package EasyIM\TencentIM\Group\Parameter\Import
12
 * @author  yingzhan <[email protected]>
13
 *
14
 */
15
class ImportMsgListParameter extends Parameter
16
{
17
    /**
18
     * @var array
19
     */
20
    protected $properties = [
21
        'From_Account',
22
        'SendTime',
23
        'MsgBody',
24
    ];
25
26
    protected $required = ['From_Account', 'SendTime', 'MsgBody'];
27
28
    /**
29
     *
30
     * @param string $value
31
     *
32
     * @return $this
33
     */
34
    public function setFromAccount(string $value)
35
    {
36
        $this->setAttribute('From_Account', $value);
37
38
        return $this;
39
    }
40
41
    /**
42
     *
43
     * @param int $value
44
     *
45
     * @return $this
46
     */
47
    public function setSendTime(int $value)
48
    {
49
        $this->setAttribute('SendTime', $value);
50
51
        return $this;
52
    }
53
54
55
    /**
56
     *
57
     * @param string $value
58
     *
59
     * @return $this
60
     */
61
    public function setRandom(string $value)
62
    {
63
        $this->setAttribute('Random', $value);
64
65
        return $this;
66
    }
67
68
    /**
69
     *
70
     * @param MessageInterface ...$value
71
     *
72
     * @return $this
73
     */
74
    public function setMsgBody(MessageInterface ...$value)
75
    {
76
        $items = [];
77
78
        foreach ($value as $item) {
79
            $items[] = $item->transformToArray([], true);
80
        }
81
82
        $this->setAttribute('MsgBody', $items);
83
84
        return $this;
85
    }
86
87
    public function transformToArray(array $appends = []): array
88
    {
89
        return parent::transformToArray(['Random' => mt_rand(1, 99999999)]);
90
    }
91
}
92