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

MediaTypeBuilder   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 5
dl 0
loc 56
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A createMediaType() 0 9 4
A setEncodings() 0 6 1
A setExamples() 0 6 1
A setSchema() 0 6 1
A getEncodings() 0 4 1
A getExamples() 0 4 1
A getSchema() 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 MediaTypeBuilder implements Objects\MediaTypeFactory
10
{
11
    use Properties\OptionalExtensions;
12
13
    private $encodings;
14
15
    private $examples;
16
17
    private $schema;
18
19
    public function createMediaType(): Objects\MediaType
20
    {
21
        return new Objects\MediaType(
22
            $this->getSchema() ? $this->getSchema()->createSchemaAggregate() : null,
23
            $this->getExamples() ? $this->getExamples()->createExamples() : null,
24
            $this->getEncodings() ? $this->getEncodings()->createEncodings() : null,
25
            $this->getExtensions()
26
        );
27
    }
28
29
    public function setEncodings(Objects\EncodingsFactory $encodings): self
30
    {
31
        $this->encodings = $encodings;
32
33
        return $this;
34
    }
35
36
    public function setExamples(Objects\ExamplesFactory $examples): self
37
    {
38
        $this->examples = $examples;
39
40
        return $this;
41
    }
42
43
    public function setSchema(Objects\SchemaAggregateFactory $schema): self
44
    {
45
        $this->schema = $schema;
46
47
        return $this;
48
    }
49
50
    private function getEncodings(): ?Objects\EncodingsFactory
51
    {
52
        return $this->encodings;
53
    }
54
55
    private function getExamples(): ?Objects\ExamplesFactory
56
    {
57
        return $this->examples;
58
    }
59
60
    private function getSchema(): ?Objects\SchemaAggregateFactory
61
    {
62
        return $this->schema;
63
    }
64
}
65