Broadcast   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A message() 0 6 1
A send() 0 4 1
1
<?php
2
3
namespace EntWeChat\Broadcast;
4
5
use EntWeChat\Core\AbstractAPI;
6
7
/**
8
 * Class Broadcast.
9
 */
10
class Broadcast extends AbstractAPI
11
{
12
    const API_MESSAGE_SEND = 'https://qyapi.weixin.qq.com/cgi-bin/message/send';
13
14
    const MSG_TYPE_TEXT = 'text';   // 文本
15
    const MSG_TYPE_NEWS = 'news';   // 图文
16
    const MSG_TYPE_VOICE = 'voice';  // 语音
17
    const MSG_TYPE_IMAGE = 'image';  // 图片
18
    const MSG_TYPE_VIDEO = 'video';  // 视频
19
    const MSG_TYPE_CARD = 'card';   // 卡券
20
    const MSG_TYPE_FILE = 'file';   // 文件
21
    const MSG_TYPE_MPNEWS = 'mpnews'; // 图文
22
    const MSG_TYPE_TEXTCARD = 'textcard'; // 文本卡片
23
24
    /**
25
     * Get message builder.
26
     *
27
     * @param \EntWeChat\Message\AbstractMessage|string $message
28
     *
29
     * @throws \EntWeChat\Core\Exceptions\InvalidArgumentException
30
     *
31
     * @return MessageBuilder
32
     */
33
    public function message($message)
34
    {
35
        $messageBuilder = new MessageBuilder($this);
36
37
        return $messageBuilder->message($message);
0 ignored issues
show
Bug introduced by
It seems like $message defined by parameter $message on line 33 can also be of type object<EntWeChat\Message\AbstractMessage>; however, EntWeChat\Broadcast\MessageBuilder::message() does only seem to accept string|array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
38
    }
39
40
    /**
41
     * Send a message.
42
     *
43
     * @param string|array $message
44
     *
45
     * @return \EntWeChat\Support\Collection
46
     */
47
    public function send($message)
48
    {
49
        return $this->parseJSON('json', [self::API_MESSAGE_SEND, $message]);
50
    }
51
}
52