Completed
Push — master ( 8f139f...a8687a )
by Joachim
04:58
created

Request   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 35
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 8 1
A getMethods() 0 10 1
A getBody() 0 4 1
A getOptions() 0 4 1
1
<?php
2
namespace Loevgaard\Linkmobility\Request;
3
4
use Assert\Assert;
5
use Assert\InvalidArgumentException;
6
use Loevgaard\Linkmobility\Response\ResponseInterface;
7
8
abstract class Request implements RequestInterface
9
{
10
    /**
11
     * @throws InvalidArgumentException
12
     */
13
    public function validate(): void
14
    {
15
        Assert::that($this->getMethod())->choice(self::getMethods());
16
        Assert::that($this->getUri())->string()->startsWith('/');
17
        Assert::that($this->getBody())->isArray();
18
        Assert::that($this->getResponseClass())->implementsInterface(ResponseInterface::class);
19
        Assert::that($this->getOptions())->isArray();
20
    }
21
22
    public static function getMethods() : array
23
    {
24
        return [
25
            RequestInterface::METHOD_GET => RequestInterface::METHOD_GET,
26
            RequestInterface::METHOD_POST => RequestInterface::METHOD_POST,
27
            RequestInterface::METHOD_PUT => RequestInterface::METHOD_PUT,
28
            RequestInterface::METHOD_PATCH => RequestInterface::METHOD_PATCH,
29
            RequestInterface::METHOD_DELETE => RequestInterface::METHOD_DELETE,
30
        ];
31
    }
32
33
    public function getBody(): array
34
    {
35
        return [];
36
    }
37
38
    public function getOptions(): array
39
    {
40
        return [];
41
    }
42
}
43