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

Example::hasExternalValue()   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 Example extends ValueObject implements ExampleAggregate
11
{
12
    use Properties\OptionalDescription;
13
    use Properties\OptionalExtensions;
14
    use Properties\OptionalSummary;
15
16
    private $externalValue;
17
18
    private $value;
19
20
    /**
21
     * @param mixed $value
22
     */
23 4
    public function __construct(
24
        string $summary = null,
25
        string $description = null,
26
        $value = null,
27
        string $externalValue = null,
28
        Extensions $extensions = null
29
    ) {
30 4
        $this->summary = $summary;
31 4
        $this->description = $description;
32 4
        $this->value = $value;
33 4
        $this->externalValue = $externalValue;
34 4
        $this->extensions = $extensions;
35
    }
36
37 1
    public function getExternalValue(): string
38
    {
39 1
        return $this->externalValue;
40
    }
41
42
    /**
43
     * @return mixed
44
     */
45 3
    public function getValue()
46
    {
47 3
        return $this->value;
48
    }
49
50 3
    public function hasExternalValue(): bool
51
    {
52 3
        return isset($this->externalValue);
53
    }
54
55 3
    public function jsonSerialize(): ?array
56
    {
57 3
        return $this->extendedProperties(parent::jsonSerialize());
58
    }
59
60 3
    protected function normalizeOptionalProperties(): array
61
    {
62
        return [
63 3
            'summary' => $this->getNormalizedSummary(),
64 3
            'description' => $this->getNormalizedDescription(),
65 3
            'value' => $this->getValue(),
66 3
            'externalValue' => $this->hasExternalValue() ? $this->getExternalValue() : null,
67
        ];
68
    }
69
}
70