Completed
Pull Request — master (#1606)
by
unknown
03:24
created

Text   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 50
ccs 12
cts 12
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A mentionByMobile() 0 5 1
A mention() 0 5 1
A __construct() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyWeChat\Work\GroupRobot\Messages;
13
14
/**
15
 * Class Text.
16
 *
17
 * @author her-cat <[email protected]>
18
 */
19
class Text extends Message
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $type = 'text';
25
26
    /**
27
     * @var array
28
     */
29
    protected $properties = ['content', 'mentioned_list', 'mentioned_mobile_list'];
30
31
    /**
32
     * Text constructor.
33
     *
34
     * @param string $content
35
     * @param string|array $userIds
36
     * @param string|array $mobiles
37
     */
38 8
    public function __construct(string $content, $userIds = [], $mobiles = [])
39
    {
40 8
        parent::__construct([
41 8
            'content' => $content,
42 8
            'mentioned_list' => (array)$userIds,
43 8
            'mentioned_mobile_list' => (array)$mobiles,
44
        ]);
45 8
    }
46
47
    /**
48
     * @param $userIds
49
     *
50
     * @return Text
51
     */
52 2
    public function mention($userIds)
53
    {
54 2
        $this->set('mentioned_list', (array)$userIds);
55
56 2
        return $this;
57
    }
58
59
    /**
60
     * @param $mobiles
61
     *
62
     * @return Text
63
     */
64 2
    public function mentionByMobile($mobiles)
65
    {
66 2
        $this->set('mentioned_mobile_list', (array)$mobiles);
67
68 2
        return $this;
69
    }
70
}
71