Request::validate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
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 1
    public function validate(): void
14
    {
15 1
        Assert::that($this->getMethod())->choice(self::getMethods());
16 1
        Assert::that($this->getUri())->string()->startsWith('/');
17 1
        Assert::that($this->getBody())->isArray();
18 1
        Assert::that($this->getResponseClass())->implementsInterface(ResponseInterface::class);
19 1
        Assert::that($this->getOptions())->isArray();
20 1
    }
21
22 1
    public static function getMethods() : array
23
    {
24
        return [
25 1
            RequestInterface::METHOD_GET => RequestInterface::METHOD_GET,
26 1
            RequestInterface::METHOD_POST => RequestInterface::METHOD_POST,
27 1
            RequestInterface::METHOD_PUT => RequestInterface::METHOD_PUT,
28 1
            RequestInterface::METHOD_PATCH => RequestInterface::METHOD_PATCH,
29 1
            RequestInterface::METHOD_DELETE => RequestInterface::METHOD_DELETE,
30
        ];
31
    }
32
33 1
    public function getBody(): array
34
    {
35 1
        return [];
36
    }
37
38 2
    public function getOptions(): array
39
    {
40 2
        return [];
41
    }
42
}
43