Completed
Push — master ( 935a4f...80b369 )
by Veaceslav
01:53
created

Discriminator::getMapping()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Objects;
6
7
use Aweapi\Openapi\ValueObject;
8
9
final class Discriminator extends ValueObject
10
{
11
    private $mapping = [];
12
13
    private $propertyName;
14
15 2
    public function __construct(
16
        string $propertyName,
17
        iterable $mapping = []
18
    ) {
19 2
        $this->propertyName = $propertyName;
20
21 2
        foreach ($mapping as $name => $reference) {
22 1
            $this->mapping[$name] = $reference;
23
        }
24
    }
25
26 2
    public function getMapping(): array
27
    {
28 2
        return $this->mapping;
29
    }
30
31 2
    public function getPropertyName(): string
32
    {
33 2
        return $this->propertyName;
34
    }
35
36 2
    protected function normalizeOptionalProperties(): array
37
    {
38
        return [
39 2
            'mapping' => $this->getMapping(),
40
        ];
41
    }
42
43 2
    protected function normalizeRequiredProperties(): array
44
    {
45
        return [
46 2
            'propertyName' => $this->getPropertyName(),
47
        ];
48
    }
49
}
50