MessageApi   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __call() 0 25 5
1
<?php
2
namespace Wechat\API;
3
4
/**
5
 * 微信被动回复.
6
 *
7
 * @author Tian.
8
 */
9
class MessageApi extends BaseApi
10
{
11
    /**
12
     * [__call 魔术方法 生成回调array]
13
     *
14
     * @param  mixed $MsgType [类型]
15
     * @param  array $datas   [参数]
16
     *
17
     * @return string xml          [XML]
18
     */
19
    public function __call($MsgType, $datas)
20
    {
21
        $MsgType = strtolower($MsgType);
22
23
        $data               = [];
24
        $data['CreateTime'] = time();
25
        $data['MsgType']    = $MsgType;
26
27
        $datas = reset($datas);
28
29
        if ($MsgType == 'text') {
30
            $data['Content'] = $datas['Content'];
31
        } elseif ($MsgType == 'news') {
32
            $data['ArticleCount'] = count($datas['item']);
33
            $data['Articles']     = $datas;
34
        } elseif ($MsgType == 'music') {
35
            $data['Music'] = $datas;
36
        } elseif ($MsgType == 'video') {
37
            $data['Video'] = $datas;
38
        } else {
39
            $data[$MsgType] = $datas;
40
        }
41
42
        return $data;
43
    }
44
}
45