Passed
Pull Request — master (#34)
by Anatoly
02:47
created

Example::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 13
ccs 0
cts 11
cp 0
rs 10
cc 2
nc 2
nop 0
crap 6
1
<?php declare(strict_types=1);
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Fenric <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Fenric
8
 * @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-router
10
 */
11
12
namespace Sunrise\Http\Router\Annotation\OpenApi;
13
14
/**
15
 * @Annotation
16
 *
17
 * @Target({"ANNOTATION"})
18
 */
19
final class Example
20
{
21
22
    /**
23
     * @var string
24
     */
25
    public $summary = '';
26
27
    /**
28
     * @var string
29
     */
30
    public $description = '';
31
32
    /**
33
     * @var string
34
     */
35
    public $value;
36
37
    /**
38
     * @var mixed
39
     */
40
    public $extendedValue;
41
42
    /**
43
     * @var string
44
     */
45
    public $externalValue;
46
47
    /**
48
     * @return array
49
     */
50
    public function toArray() : array
51
    {
52
        $result = [
53
            'summary' => $this->summary,
54
            'description' => $this->description,
55
            'value' => $this->extendedValue ?? $this->value,
56
        ];
57
58
        if (isset($this->externalValue)) {
59
            $result['externalValue'] = $this->externalValue;
60
        }
61
62
        return $result;
63
    }
64
}
65