ImportMsgListParameter::setFromAccount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
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