Completed
Push — master ( 9a89be...b03325 )
by light
38:59
created

Translate::dictionary()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
rs 9.4286
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the light/yii2-apistore.
5
 *
6
 * (c) lichunqiang <[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 light\apistore\apis;
13
14
/**
15
 * 翻译.
16
 *
17
 * @see http://apistore.baidu.com/apiworks/servicedetail/118.html
18
 */
19
class Translate extends Api
20
{
21
    private $address_translate = 'http://apis.baidu.com/apistore/tranlateservice/translate?';
22
23
    /**
24
     * 目前词典接口只支持zh和en两种语言
25
     *
26
     * @param string $query 请求的词语或待翻译的内容,UTF-8,urlencode编码
0 ignored issues
show
Bug introduced by
There is no parameter named $query. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
27
     * @param string $from  源语言语种:语言代码或auto
0 ignored issues
show
Bug introduced by
There is no parameter named $from. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
28
     * @param string $to    目标语言语种:语言代码或auto
0 ignored issues
show
Bug introduced by
There is no parameter named $to. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
29
     *
30
     * @return array
31
     */
32
    public function get($queryParams)
33
    {
34
        $_using_address = $this->address_translate;
35
36
        if (is_string($queryParams)) {
37
            $queryParams = ['query' => $queryParams, 'from' => 'auto', 'to' => 'auto'];
38
        } elseif (!isset($queryParams['query'])) {
39
            $queryParams = array_combine(['query', 'from', 'to'], $queryParams);
40
        }
41
42
        return $this->fetch($_using_address . http_build_query($queryParams));
43
    }
44
}
45