Api::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Devhelp\Piwik\Api;
4
5
use Devhelp\Piwik\Api\Client\PiwikClient;
6
use Devhelp\Piwik\Api\Method\Method;
7
8
/**
9
 * Creates Method objects using predefined set of arguments,
10
 * so that all methods will share the same basic set of them
11
 */
12
class Api
13
{
14
15
    private $piwikClient;
16
17
    private $url;
18
19
    private $defaultParams = array();
20
21
    public function __construct(PiwikClient $piwikClient, $url)
22
    {
23
        $this->piwikClient = $piwikClient;
24
        $this->url = $url;
25
    }
26
27
    public function setDefaultParams(array $params)
28
    {
29
        $this->defaultParams = $params;
30
    }
31
32
    public function getDefaultParams()
33
    {
34
        return $this->defaultParams;
35
    }
36
37
    /**
38
     * @param string $methodName
39
     * @return Method
40
     */
41
    public function getMethod($methodName)
42
    {
43
        $method = new Method($this->piwikClient, $this->url, $methodName);
44
45
        $method->setDefaultParams($this->getDefaultParams());
46
47
        return $method;
48
    }
49
}
50