Completed
Push — master ( 387ec3...961eec )
by Pieter
06:24
created

BaseRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

4 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
1
<?php declare(strict_types=1);
2
3
namespace PeeHaa\AsyncTwitter\Api\Request;
4
5
use PeeHaa\AsyncTwitter\Request\Parameter;
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 113
    public function __construct(string $method, string $endpoint)
19
    {
20 113
        $this->method   = $method;
21 113
        $this->endpoint = $endpoint;
22 113
    }
23
24 1
    public function getMethod(): string
25
    {
26 1
        return $this->method;
27
    }
28
29 56
    public function getParameters(): array
30
    {
31 56
        $parameters = [];
32
33 56
        foreach ($this->parameters as $key => $value) {
34 56
            $parameters[] = new Parameter($key, $value);
35
        }
36
37 56
        return $parameters;
38
    }
39
40 1
    public function getEndpoint(): Url
41
    {
42 1
        return new Url(static::BASE_URL, $this->endpoint);
43
    }
44
}
45