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

Discriminator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 1
dl 0
loc 41
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getMapping() 0 4 1
A getPropertyName() 0 4 1
A normalizeOptionalProperties() 0 6 1
A normalizeRequiredProperties() 0 6 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