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

EncodingBuilder   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 3
dl 0
loc 86
ccs 33
cts 33
cp 1
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 4
    public function createEncoding(): Objects\Encoding
24
    {
25 4
        return new Objects\Encoding(
26 4
            $this->getContentType(),
27 4
            $this->getHeaders() ? $this->getHeaders()->createHeaders() : null,
28 4
            $this->getStyle(),
29 4
            $this->isExplode(),
30 4
            $this->isAllowReserved(),
31 4
            $this->getExtensions()
32
        );
33
    }
34
35 1
    public function setAllowReserved(bool $allowReserved): self
36
    {
37 1
        $this->allowReserved = $allowReserved;
38
39 1
        return $this;
40
    }
41
42 3
    public function setContentType(string $contentType): self
43
    {
44 3
        $this->contentType = $contentType;
45
46 3
        return $this;
47
    }
48
49 1
    public function setExplode(bool $explode): self
50
    {
51 1
        $this->explode = $explode;
52
53 1
        return $this;
54
    }
55
56 1
    public function setHeaders(Objects\HeadersFactory $headers): self
57
    {
58 1
        $this->headers = $headers;
59
60 1
        return $this;
61
    }
62
63 1
    public function setStyle(string $style): self
64
    {
65 1
        $this->style = $style;
66
67 1
        return $this;
68
    }
69
70 4
    private function getContentType(): ?string
71
    {
72 4
        return $this->contentType;
73
    }
74
75 4
    private function getHeaders(): ?Objects\HeadersFactory
76
    {
77 4
        return $this->headers;
78
    }
79
80 4
    private function getStyle(): ?string
81
    {
82 4
        return $this->style;
83
    }
84
85 4
    private function isAllowReserved(): bool
86
    {
87 4
        return $this->allowReserved;
88
    }
89
90 4
    private function isExplode(): bool
91
    {
92 4
        return $this->explode;
93
    }
94
}
95