BaseRequest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethod() 0 4 1
A getParameters() 0 10 2
A getEndpoint() 0 4 1
A __construct() 0 5 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 339
    public function __construct(string $method, string $endpoint)
19
    {
20 339
        $this->method   = $method;
21 339
        $this->endpoint = $endpoint;
22
    }
23
24 1
    public function getMethod(): string
25
    {
26 1
        return $this->method;
27
    }
28
29 183
    public function getParameters(): array
30
    {
31 183
        $parameters = [];
32
33 183
        foreach ($this->parameters as $key => $value) {
34 183
            $parameters[] = new FieldParameter($key, $value);
35
        }
36
37 183
        return $parameters;
38
    }
39
40 13
    public function getEndpoint(): Url
41
    {
42 13
        return new Url(static::BASE_URL, $this->endpoint);
43
    }
44
45
    public function handleResponse(array $responseData)
46
    {
47
        return $responseData;
48
    }
49
}
50