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

Contact   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 3
dl 0
loc 55
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getEmail() 0 4 1
A getName() 0 4 1
A hasEmail() 0 4 1
A hasName() 0 4 1
A jsonSerialize() 0 4 1
A normalizeOptionalProperties() 0 8 3
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 Contact extends ValueObject
11
{
12
    use Properties\OptionalExtensions;
13
    use Properties\OptionalUrl;
14
15
    private $email;
16
17
    private $name;
18
19 3
    public function __construct(
20
        string $name = null,
21
        string $url = null,
22
        string $email = null,
23
        Extensions $extensions = null
24
    ) {
25 3
        $this->name = $name;
26 3
        $this->url = $url;
27 3
        $this->email = $email;
28 3
        $this->extensions = $extensions;
29
    }
30
31 1
    public function getEmail(): string
32
    {
33 1
        return $this->email;
34
    }
35
36 2
    public function getName(): string
37
    {
38 2
        return $this->name;
39
    }
40
41 3
    public function hasEmail(): bool
42
    {
43 3
        return isset($this->email);
44
    }
45
46 3
    public function hasName(): bool
47
    {
48 3
        return isset($this->name);
49
    }
50
51 3
    public function jsonSerialize(): ?array
52
    {
53 3
        return $this->extendedProperties(parent::jsonSerialize());
54
    }
55
56 3
    protected function normalizeOptionalProperties(): array
57
    {
58
        return [
59 3
            'name' => $this->hasName() ? $this->getName() : null,
60 3
            'url' => $this->getNormalizedUrl(),
61 3
            'email' => $this->hasEmail() ? $this->getEmail() : null,
62
        ];
63
    }
64
}
65