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

DiscriminatorBuilder::createDiscriminator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Builders;
6
7
use Aweapi\Openapi\Objects;
8
9
final class DiscriminatorBuilder implements Objects\DiscriminatorFactory
10
{
11
    private $mapping = [];
12
13
    private $propertyName;
14
15
    public function createDiscriminator(): Objects\Discriminator
16
    {
17
        return new Objects\Discriminator(
18
            $this->getPropertyName(),
19
            $this->getMapping()
20
        );
21
    }
22
23
    public function setMapping(array $mapping): self
24
    {
25
        $this->mapping = $mapping;
26
27
        return $this;
28
    }
29
30
    public function setPropertyName(string $propertyName): self
31
    {
32
        $this->propertyName = $propertyName;
33
34
        return $this;
35
    }
36
37
    private function getMapping(): array
38
    {
39
        return $this->mapping;
40
    }
41
42
    private function getPropertyName(): ?string
43
    {
44
        return $this->propertyName;
45
    }
46
}
47