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

License::jsonSerialize()   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\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