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

Request::getBody()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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