Completed
Pull Request — master (#4)
by Veaceslav
02:34
created

License   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
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 9 1
A getName() 0 4 1
A jsonSerialize() 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\Extensions;
8
use Aweapi\Openapi\ValueObject;
9
10
final class License extends ValueObject
11
{
12
    use Properties\OptionalExtensions;
13
    use Properties\OptionalUrl;
14
15
    private $name;
16
17 3
    public function __construct(
18
        string $name,
19
        string $url = null,
20
        Extensions $extensions = null
21
    ) {
22 3
        $this->name = $name;
23 3
        $this->url = $url;
24 3
        $this->extensions = $extensions;
25
    }
26
27 3
    public function getName(): string
28
    {
29 3
        return $this->name;
30
    }
31
32 3
    public function jsonSerialize(): ?array
33
    {
34 3
        return $this->extendedProperties(parent::jsonSerialize());
35
    }
36
37 3
    protected function normalizeOptionalProperties(): array
38
    {
39
        return [
40 3
            'url' => $this->getNormalizedUrl(),
41
        ];
42
    }
43
44 3
    protected function normalizeRequiredProperties(): array
45
    {
46
        return [
47 3
            'name' => $this->getName(),
48
        ];
49
    }
50
}
51