Completed
Pull Request — master (#6)
by Veaceslav
11:19
created

EncodingBuilder   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 3
dl 0
loc 86
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A createEncoding() 0 11 2
A setAllowReserved() 0 6 1
A setContentType() 0 6 1
A setExplode() 0 6 1
A setHeaders() 0 6 1
A setStyle() 0 6 1
A getContentType() 0 4 1
A getHeaders() 0 4 1
A getStyle() 0 4 1
A isAllowReserved() 0 4 1
A isExplode() 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 EncodingBuilder implements Objects\EncodingFactory
10
{
11
    use Properties\OptionalExtensions;
12
13
    private $allowReserved = false;
14
15
    private $contentType;
16
17
    private $explode = true;
18
19
    private $headers;
20
21
    private $style;
22
23
    public function createEncoding(): Objects\Encoding
24
    {
25
        return new Objects\Encoding(
26
            $this->getContentType(),
27
            $this->getHeaders() ? $this->getHeaders()->createHeaders() : null,
28
            $this->getStyle(),
29
            $this->isExplode(),
30
            $this->isAllowReserved(),
31
            $this->getExtensions()
32
        );
33
    }
34
35
    public function setAllowReserved(bool $allowReserved): self
36
    {
37
        $this->allowReserved = $allowReserved;
38
39
        return $this;
40
    }
41
42
    public function setContentType(string $contentType): self
43
    {
44
        $this->contentType = $contentType;
45
46
        return $this;
47
    }
48
49
    public function setExplode(bool $explode): self
50
    {
51
        $this->explode = $explode;
52
53
        return $this;
54
    }
55
56
    public function setHeaders(Objects\HeadersFactory $headers): self
57
    {
58
        $this->headers = $headers;
59
60
        return $this;
61
    }
62
63
    public function setStyle(string $style): self
64
    {
65
        $this->style = $style;
66
67
        return $this;
68
    }
69
70
    private function getContentType(): ?string
71
    {
72
        return $this->contentType;
73
    }
74
75
    private function getHeaders(): ?Objects\HeadersFactory
76
    {
77
        return $this->headers;
78
    }
79
80
    private function getStyle(): ?string
81
    {
82
        return $this->style;
83
    }
84
85
    private function isAllowReserved(): bool
86
    {
87
        return $this->allowReserved;
88
    }
89
90
    private function isExplode(): bool
91
    {
92
        return $this->explode;
93
    }
94
}
95