Completed
Push — v3 ( d12fea...862d0b )
by Beñat
03:42
created

AnswersOfIdsCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 58
wmc 5
lcom 0
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
A url() 0 4 1
A params() 0 4 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
 * Answers of ids command.
16
 *
17
 * @author Beñat Espiña <[email protected]>
18
 */
19
class AnswersOfIdsCommand
20
{
21
    const URL = '/answers/%s';
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|string $id     The answer id. Also, it can be multiple ids separated by semicolon.
41
     * @param array        $params Array that contains StackExchange API params
42
     */
43
    public function __construct($id, array $params = ['site' => 'stackoverflow'])
44
    {
45
        if (empty($params)) {
46
            $params = [
47
                'order' => 'desc',
48
                'sort'  => 'activity',
49
                'site'  => 'stackoverflow',
50
            ];
51
        }
52
53
        $this->params = $params;
54
        $this->url = sprintf(self::URL, is_array($id) ? implode(';', $id) : $id);
55
    }
56
57
    /**
58
     * The API URL.
59
     *
60
     * @return string
61
     */
62
    public function url()
63
    {
64
        return $this->url;
65
    }
66
67
    /**
68
     * Gets the params.
69
     *
70
     * @return array
71
     */
72
    public function params()
73
    {
74
        return $this->params;
75
    }
76
}
77