Test Failed
Pull Request — master (#34)
by Anatoly
02:07
created

Example   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 2
b 0
f 0
dl 0
loc 64
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getComponentName() 0 3 1
A getReferenceName() 0 3 1
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
 * Import classes
16
 */
17
use Sunrise\Http\Router\OpenApi\ComponentObjectInterface;
18
19
/**
20
 * Import functions
21
 */
22
use function spl_object_hash;
23
24
/**
25
 * @Annotation
26
 *
27
 * @Target({"ALL"})
28
 *
29
 * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#example-object
30
 */
31
final class Example extends AbstractAnnotation implements ExampleInterface, ComponentObjectInterface
32
{
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    protected const IGNORE_FIELDS = ['refName'];
38
39
    /**
40
     * {@inheritDoc}
41
     */
42
    protected const FIELD_ALIASES = ['anyValue' => 'value'];
43
44
    /**
45
     * @var string
46
     */
47
    public $refName;
48
49
    /**
50
     * @var string
51
     *
52
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-examplesummary
53
     */
54
    public $summary;
55
56
    /**
57
     * @var string
58
     *
59
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-exampledescription
60
     */
61
    public $description;
62
63
    /**
64
     * This property cannot be named as "value" because the name is reserved by the Doctrine Annotations Library.
65
     *
66
     * @see https://github.com/doctrine/annotations/blob/b4fde48ffe28bf766077f8d41b5d23049a0687a8/lib/Doctrine/Common/Annotations/DocParser.php#L786
67
     *
68
     * @var mixed
69
     *
70
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-examplevalue
71
     */
72
    public $anyValue;
73
74
    /**
75
     * @var string
76
     *
77
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-exampleexternalvalue
78
     */
79
    public $externalValue;
80
81
    /**
82
     * {@inheritDoc}
83
     */
84
    public function getComponentName() : string
85
    {
86
        return 'examples';
87
    }
88
89
    /**
90
     * {@inheritDoc}
91
     */
92
    public function getReferenceName() : string
93
    {
94
        return $this->refName ?? spl_object_hash($this);
95
    }
96
}
97