PiwikGuzzleClient   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setRequestMethod() 0 4 1
A call() 0 4 1
1
<?php
2
3
namespace Devhelp\Piwik\Api\Guzzle\Client;
4
5
use Devhelp\Piwik\Api\Client\PiwikClient;
6
use GuzzleHttp\ClientInterface;
7
use Psr\Http\Message\ResponseInterface;
8
9
/**
10
 * Wrapper for guzzle http client for the Method class
11
 */
12
class PiwikGuzzleClient implements PiwikClient
13
{
14
    /**
15
     * @var ClientInterface
16
     */
17
    private $guzzleClient;
18
19
    private $method = 'post';
20
21
    public function __construct(ClientInterface $guzzleClient)
22
    {
23
        $this->guzzleClient = $guzzleClient;
24
    }
25
26
    public function setRequestMethod($method)
27
    {
28
        $this->method = $method;
29
    }
30
31
    /**
32
     * @param string $url base piwik api url
33
     * @param array $params api parameters
34
     * @return ResponseInterface
35
     */
36
    public function call($url, array $params = [])
37
    {
38
        return $this->guzzleClient->request($this->method, $url, ['query' => $params]);
39
    }
40
}
41