Completed
Push — master ( 9a985e...77d1e9 )
by Pieter
02:27
created

BaseRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 2
dl 0
loc 35
ccs 0
cts 21
cp 0
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
    private $method;
11
12
    private $endpoint;
13
14
    protected $parameters = [];
15
16
    public function __construct(string $method, string $endpoint)
17
    {
18
        $this->method   = $method;
19
        $this->endpoint = $endpoint;
20
    }
21
22
    public function getMethod(): string
23
    {
24
        return $this->method;
25
    }
26
27
    public function getParameters(): array
28
    {
29
        $parameters = [];
30
31
        foreach ($this->parameters as $key => $value) {
32
            $parameters[] = new Parameter($key, $value);
33
        }
34
35
        return $parameters;
36
    }
37
38
    public function getEndpoint(): Url
39
    {
40
        return new Url($this->endpoint);
41
    }
42
}
43