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

AcceptAnswerCommand::url()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace BenatEspina\StackExchangeApiClient\Application\Service\Answer;
4
5
/**
6
 * Accept answer command.
7
 *
8
 * @author Beñat Espiña <[email protected]>
9
 */
10 View Code Duplication
class AcceptAnswerCommand
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/%s/accept';
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|string $id     The answer id. Also, it can be multiple ids separated by semicolon.
32
     * @param array        $params Array that contains StackExchange API params
33
     */
34
    public function __construct($id, array $params = ['site' => 'stackoverflow'])
35
    {
36
        if (empty($params)) {
37
            $params = [
38
                'order' => 'desc',
39
                'sort'  => 'activity',
40
                'site'  => 'stackoverflow',
41
            ];
42
        }
43
44
        $this->params = $params;
45
        $this->url = sprintf(self::URL, $id);
46
    }
47
48
    /**
49
     * The API URL.
50
     *
51
     * @return string
52
     */
53
    public function url()
54
    {
55
        return $this->url;
56
    }
57
58
    /**
59
     * Gets the params.
60
     *
61
     * @return array
62
     */
63
    public function params()
64
    {
65
        return $this->params;
66
    }
67
}
68