Completed
Push — v3 ( d12fea...862d0b )
by Beñat
03:42
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
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * Copyright (c) 2014-2016 Beñat Espiña <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace BenatEspina\StackExchangeApiClient\Application\Service\Answer;
13
14
/**
15
 * All answers command.
16
 *
17
 * @author Beñat Espiña <[email protected]>
18
 */
19 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...
20
{
21
    const URL = '/answers';
22
23
    /**
24
     * The API URL.
25
     *
26
     * @var string
27
     */
28
    private $url;
29
30
    /**
31
     * Array that contains StackExchange API params.
32
     *
33
     * @var array
34
     */
35
    private $params;
36
37
    /**
38
     * Constructor.
39
     *
40
     * @param array $params Array that contains StackExchange API params
41
     */
42
    public function __construct(array $params = ['site' => 'stackoverflow'])
43
    {
44
        if (empty($params)) {
45
            $params = [
46
                'order' => 'desc',
47
                'sort'  => 'activity',
48
                'site'  => 'stackoverflow',
49
            ];
50
        }
51
52
        $this->params = $params;
53
        $this->url = self::URL;
54
    }
55
56
    /**
57
     * The API URL.
58
     *
59
     * @return string
60
     */
61
    public function url()
62
    {
63
        return $this->url;
64
    }
65
66
    /**
67
     * Gets the params.
68
     *
69
     * @return array
70
     */
71
    public function params()
72
    {
73
        return $this->params;
74
    }
75
}
76