Completed
Push — master ( 9e0ead...983405 )
by Carlos
11:10 queued 08:26
created

Semantic   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 24
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A query() 0 10 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
/**
13
 * Semantic.php.
14
 *
15
 * @author    overtrue <[email protected]>
16
 * @copyright 2015 overtrue <[email protected]>
17
 *
18
 * @link      https://github.com/overtrue
19
 * @link      http://overtrue.me
20
 */
21
namespace EasyWeChat\Semantic;
22
23
use EasyWeChat\Core\AbstractAPI;
24
25
/**
26
 * Class Semantic.
27
 */
28
class Semantic extends AbstractAPI
29
{
30
    const API_SEARCH = 'https://api.weixin.qq.com/semantic/semproxy/search';
31
32
    /**
33
     * Get the semantic content of giving string.
34
     *
35
     * @param string       $keyword
36
     * @param array|string $categories
37
     * @param array        $other
38
     *
39
     * @return array
40
     */
41 1
    public function query($keyword, $categories, array $other = [])
42
    {
43
        $params = [
44 1
                   'query' => $keyword,
45 1
                   'category' => implode(',', (array) $categories),
46 1
                   'appid' => $this->getAccessToken()->getAppId(),
47 1
                  ];
48
49 1
        return $this->parseJSON('json', [self::API_SEARCH, array_merge($params, $other)]);
50
    }
51
}
52