Completed
Push — master ( c42e36...b38be8 )
by
unknown
08:24 queued 05:17
created

BaseRequest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 2
dl 0
loc 42
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getMethod() 0 4 1
A getParameters() 0 10 2
A getEndpoint() 0 4 1
A handleResponse() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace PeeHaa\AsyncTwitter\Api\Request;
4
5
use PeeHaa\AsyncTwitter\Request\FieldParameter;
6
use PeeHaa\AsyncTwitter\Request\Url;
7
8
abstract class BaseRequest implements Request
9
{
10
    const BASE_URL = 'https://api.twitter.com/1.1';
11
12
    private $method;
13
14
    private $endpoint;
15
16
    protected $parameters = [];
17
18 224
    public function __construct(string $method, string $endpoint)
19
    {
20 224
        $this->method   = $method;
21 224
        $this->endpoint = $endpoint;
22 224
    }
23
24 1
    public function getMethod(): string
25
    {
26 1
        return $this->method;
27
    }
28
29 114
    public function getParameters(): array
30
    {
31 114
        $parameters = [];
32
33 114
        foreach ($this->parameters as $key => $value) {
34 114
            $parameters[] = new FieldParameter($key, $value);
35
        }
36
37 114
        return $parameters;
38
    }
39
40 2
    public function getEndpoint(): Url
41
    {
42 2
        return new Url(static::BASE_URL, $this->endpoint);
43
    }
44
45
    public function handleResponse(array $responseData)
46
    {
47
        return $responseData;
48
    }
49
}
50