Completed
Push — master ( a8e7f2...dae442 )
by Nicolas
8s
created

AbstractApi::setParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Akeneo\Crowdin\Api;
4
5
use Akeneo\Crowdin\Client;
6
7
/**
8
 * Abstract API
9
 *
10
 * @author Nicolas Dupont <[email protected]>
11
 */
12
abstract class AbstractApi implements ApiInterface
13
{
14
    /** @var Client */
15
    protected $client;
16
17
    /**
18
     * The method parameters
19
     *
20
     * @var array
21
     */
22
    protected $parameters = [];
23
    
24
    /**
25
     * The url parameters
26
     *
27
     * @var array
28
     */
29
    protected $urlParameters =  [];
30
31
    /**
32
     * Instantiate an API
33
     *
34
     * @param Client $client
35
     */
36
    public function __construct(Client $client)
37
    {
38
        $this->client = $client;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function setParameters(array $parameters)
45
    {
46
        $this->parameters = $parameters;
47
    }
48
    
49
    /**
50
     * 
51
     * @param string $key
52
     * @param string $value
53
     * @return AbstractApi
54
     */
55
    public function addUrlParameter($key, $value)
56
    {
57
        $this->urlParameters[$key] = $value;
58
        
59
        return $this;
60
    }
61
    
62
    /**
63
     * 
64
     * @return string
65
     */
66
    protected function getUrlQueryString()
67
    {
68
        return http_build_query($this->urlParameters);
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    abstract public function execute();
75
}
76