Completed
Push — v3 ( d12fea )
by Beñat
05:39
created

AllAnswersCommand::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 13
loc 13
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
1
<?php
2
3
namespace BenatEspina\StackExchangeApiClient\Application\Service\Answer;
4
5
/**
6
 * All answers command.
7
 *
8
 * @author Beñat Espiña <[email protected]>
9
 */
10 View Code Duplication
class AllAnswersCommand
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...
11
{
12
    const URL = '/answers';
13
14
    /**
15
     * The API URL.
16
     *
17
     * @var string
18
     */
19
    private $url;
20
21
    /**
22
     * Array that contains StackExchange API params.
23
     *
24
     * @var array
25
     */
26
    private $params;
27
28
    /**
29
     * Constructor.
30
     *
31
     * @param array $params Array that contains StackExchange API params
32
     */
33
    public function __construct(array $params = ['site' => 'stackoverflow'])
34
    {
35
        if (empty($params)) {
36
            $params = [
37
                'order' => 'desc',
38
                'sort'  => 'activity',
39
                'site'  => 'stackoverflow',
40
            ];
41
        }
42
43
        $this->params = $params;
44
        $this->url = self::URL;
45
    }
46
47
    /**
48
     * The API URL.
49
     *
50
     * @return string
51
     */
52
    public function url()
53
    {
54
        return $this->url;
55
    }
56
57
    /**
58
     * Gets the params.
59
     *
60
     * @return array
61
     */
62
    public function params()
63
    {
64
        return $this->params;
65
    }
66
}
67