OpenApiBuilder::setExternalDocs()   A
last analyzed

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 OpenApiBuilder implements Objects\OpenApiFactory
10
{
11
    use Properties\OptionalExtensions;
12
13
    private $components;
14
15
    private $externalDocs;
16
17
    private $info;
18
19
    private $openapi;
20
21
    private $paths;
22
23
    private $security;
24
25
    private $servers;
26
27
    private $tags;
28
29 2
    public function createOpenApi(): Objects\OpenApi
30
    {
31 2
        return new Objects\OpenApi(
32 2
            $this->getOpenapi(),
33 2
            $this->getInfo()->createInfo(),
34 2
            $this->getPaths()->createPaths(),
35 2
            $this->getServers() ? $this->getServers()->createServerCollection() : null,
36 2
            $this->getComponents() ? $this->getComponents()->createComponents() : null,
37 2
            $this->getSecurity() ? $this->getSecurity()->createSecurityRequirementCollection() : null,
38 2
            $this->getTags() ? $this->getTags()->createTagCollection() : null,
39 2
            $this->getExternalDocs() ? $this->getExternalDocs()->createExternalDocumentation() : null,
40 2
            $this->getExtensions()
41
        );
42
    }
43
44 1
    public function setComponents(Objects\ComponentsFactory $components): self
45
    {
46 1
        $this->components = $components;
47
48 1
        return $this;
49
    }
50
51 1
    public function setExternalDocs(Objects\ExternalDocumentationFactory $externalDocs): self
52
    {
53 1
        $this->externalDocs = $externalDocs;
54
55 1
        return $this;
56
    }
57
58 2
    public function setInfo(Objects\InfoFactory $infoFactory): self
59
    {
60 2
        $this->info = $infoFactory;
61
62 2
        return $this;
63
    }
64
65 2
    public function setOpenapi(string $openapi): self
66
    {
67 2
        $this->openapi = $openapi;
68
69 2
        return $this;
70
    }
71
72 2
    public function setPaths(Objects\PathsFactory $pathsFactory): self
73
    {
74 2
        $this->paths = $pathsFactory;
75
76 2
        return $this;
77
    }
78
79 1
    public function setSecurity(Objects\SecurityRequirementCollectionFactory $security): self
80
    {
81 1
        $this->security = $security;
82
83 1
        return $this;
84
    }
85
86 1
    public function setServers(Objects\ServerCollectionFactory $servers): self
87
    {
88 1
        $this->servers = $servers;
89
90 1
        return $this;
91
    }
92
93 1
    public function setTags(Objects\TagCollectionFactory $tags): self
94
    {
95 1
        $this->tags = $tags;
96
97 1
        return $this;
98
    }
99
100 2
    private function getComponents(): ?Objects\ComponentsFactory
101
    {
102 2
        return $this->components;
103
    }
104
105 2
    private function getExternalDocs(): ?Objects\ExternalDocumentationFactory
106
    {
107 2
        return $this->externalDocs;
108
    }
109
110 2
    private function getInfo(): Objects\InfoFactory
111
    {
112 2
        return $this->info;
113
    }
114
115 2
    private function getOpenapi(): string
116
    {
117 2
        return $this->openapi;
118
    }
119
120 2
    private function getPaths(): Objects\PathsFactory
121
    {
122 2
        return $this->paths;
123
    }
124
125 2
    private function getSecurity(): ?Objects\SecurityRequirementCollectionFactory
126
    {
127 2
        return $this->security;
128
    }
129
130 2
    private function getServers(): ?Objects\ServerCollectionFactory
131
    {
132 2
        return $this->servers;
133
    }
134
135 2
    private function getTags(): ?Objects\TagCollectionFactory
136
    {
137 2
        return $this->tags;
138
    }
139
}
140