Request   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 35
ccs 17
cts 17
cp 1
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 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