Tag   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 45
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getName() 0 4 1
A jsonSerialize() 0 4 1
A normalizeOptionalProperties() 0 7 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 Tag extends ValueObject
11
{
12
    use Properties\OptionalDescription;
13
    use Properties\OptionalExternalDocs;
14
    use Properties\OptionalExtensions;
15
16
    private $name;
17
18 8
    public function __construct(
19
        string $name,
20
        string $description = null,
21
        ExternalDocumentation $externalDocs = null,
22
        Extensions $extensions = null
23
    ) {
24 8
        $this->name = $name;
25 8
        $this->description = $description;
26 8
        $this->externalDocs = $externalDocs;
27 8
        $this->extensions = $extensions;
28
    }
29
30 8
    public function getName(): string
31
    {
32 8
        return $this->name;
33
    }
34
35 8
    public function jsonSerialize(): ?array
36
    {
37 8
        return $this->extendedProperties(parent::jsonSerialize());
38
    }
39
40 8
    protected function normalizeOptionalProperties(): array
41
    {
42
        return [
43 8
            'description' => $this->getNormalizedDescription(),
44 8
            'externalDocs' => $this->getNormalizedExternalDocs(),
45
        ];
46
    }
47
48 8
    protected function normalizeRequiredProperties(): array
49
    {
50
        return [
51 8
            'name' => $this->getName(),
52
        ];
53
    }
54
}
55