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

ServerBuilder   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 3
dl 0
loc 56
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A createServer() 0 9 2
A setDescription() 0 6 1
A setUrl() 0 6 1
A setVariables() 0 6 1
A getDescription() 0 4 1
A getUrl() 0 4 1
A getVariables() 0 4 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 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