PullWord::get()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 10
loc 10
ccs 7
cts 7
cp 1
rs 9.4286
cc 3
eloc 6
nc 3
nop 1
crap 3
1
<?php
2
3
/*
4
 * This file is part of the light/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
 * @see http://apistore.baidu.com/apiworks/servicedetail/143.html
16
 */
17 View Code Duplication
class PullWord extends Api
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    private $address = 'http://apis.baidu.com/apistore/pullword/words?';
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    protected $isJsonResponse = false;
28
29
    /**
30
     * @return string
31
     */
32 2
    public function get($queryParams)
33
    {
34 2
        if (is_string($queryParams)) {
35 1
            $queryParams = ['source' => $queryParams, 'param1' => 0, 'param2' => 1];
36 2
        } elseif (!isset($queryParams['source'])) {
37 1
            $queryParams = array_combine(['source', 'param1', 'param2'], $queryParams);
38 1
        }
39
40 2
        return $this->fetch($this->address . http_build_query($queryParams));
41
    }
42
}
43