Completed
Push — master ( 00d376...cc54a0 )
by Veaceslav
01:15
created

ResponseBuilder::setDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Builders;
6
7
use Aweapi\Openapi\Objects;
8
9
final class ResponseBuilder implements Objects\ResponseFactory
10
{
11
    use Properties\OptionalExtensions;
12
13
    private $content;
14
15
    private $description;
16
17
    private $headers;
18
19
    private $links;
20
21 8
    public function createResponse(): Objects\Response
22
    {
23 8
        return new Objects\Response(
24 8
            $this->getDescription(),
25 8
            $this->getHeaders() ? $this->getHeaders()->createHeaders() : null,
26 8
            $this->getContent() ? $this->getContent()->createMediaTypes() : null,
27 8
            $this->getLinks() ? $this->getLinks()->createLinks() : null,
28 8
            $this->getExtensions()
29
        );
30
    }
31
32 2
    public function createResponseAggregate(): Objects\ResponseAggregate
33
    {
34 2
        return $this->createResponse();
35
    }
36
37
    public function setContent(Objects\MediaTypesFactory $content): self
38
    {
39
        $this->content = $content;
40
41
        return $this;
42
    }
43
44 8
    public function setDescription(string $description): self
45
    {
46 8
        $this->description = $description;
47
48 8
        return $this;
49
    }
50
51 1
    public function setHeaders(Objects\HeadersFactory $headers): self
52
    {
53 1
        $this->headers = $headers;
54
55 1
        return $this;
56
    }
57
58 1
    public function setLinks(Objects\LinksFactory $links): self
59
    {
60 1
        $this->links = $links;
61
62 1
        return $this;
63
    }
64
65 8
    private function getContent(): ?Objects\MediaTypesFactory
66
    {
67 8
        return $this->content;
68
    }
69
70 8
    private function getDescription(): string
71
    {
72 8
        return $this->description;
73
    }
74
75 8
    private function getHeaders(): ?Objects\HeadersFactory
76
    {
77 8
        return $this->headers;
78
    }
79
80 8
    private function getLinks(): ?Objects\LinksFactory
81
    {
82 8
        return $this->links;
83
    }
84
}
85