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

ServerBuilder::createServer()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Builders;
6
7
use Aweapi\Openapi\Objects;
8
9
final class ServerBuilder implements Objects\ServerFactory
10
{
11
    use Properties\OptionalExtensions;
12
13
    private $description;
14
15
    private $url;
16
17
    private $variables;
18
19 7
    public function createServer(): Objects\Server
20
    {
21 7
        return new Objects\Server(
22 7
            $this->getUrl(),
23 7
            $this->getDescription(),
24 7
            $this->getVariables() ? $this->getVariables()->createServerVariables() : null,
25 7
            $this->getExtensions()
26
        );
27
    }
28
29 1
    public function setDescription(string $description): self
30
    {
31 1
        $this->description = $description;
32
33 1
        return $this;
34
    }
35
36 7
    public function setUrl(string $url): self
37
    {
38 7
        $this->url = $url;
39
40 7
        return $this;
41
    }
42
43 1
    public function setVariables(Objects\ServerVariablesFactory $variables): self
44
    {
45 1
        $this->variables = $variables;
46
47 1
        return $this;
48
    }
49
50 7
    private function getDescription(): ?string
51
    {
52 7
        return $this->description;
53
    }
54
55 7
    private function getUrl(): string
56
    {
57 7
        return $this->url;
58
    }
59
60 7
    private function getVariables(): ?Objects\ServerVariablesFactory
61
    {
62 7
        return $this->variables;
63
    }
64
}
65