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

Operation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 18
c 0
b 0
f 0
dl 0
loc 49
ccs 0
cts 16
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 18 3
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\OpenApi\Annotation\OpenApi;
13
14
/**
15
 * @Annotation
16
 *
17
 * @Target({"CLASS"})
18
 */
19
final class Operation
20
{
21
22
    /**
23
     * @var array<string>
24
     */
25
    public $tags = [];
26
27
    /**
28
     * @var string
29
     */
30
    public $summary = '';
31
32
    /**
33
     * @var string
34
     */
35
    public $description = '';
36
37
    /**
38
     * @var array<Sunrise\Http\Router\OpenApi\Annotation\OpenApi\Parameter>
39
     */
40
    public $parameters = [];
41
42
    /**
43
     * @var array<Sunrise\Http\Router\OpenApi\Annotation\OpenApi\Response>
44
     */
45
    public $responses = [];
46
47
    /**
48
     * @return array
49
     */
50
    public function toArray() : array
51
    {
52
        $parameters = [];
53
        foreach ($this->parameters as $value) {
54
            $parameters[] = $value->toArray();
55
        }
56
57
        $responses = [];
58
        foreach ($this->responses as $value) {
59
            $responses[$value->code] = $value->toArray();
60
        }
61
62
        return [
63
            'tags' => $this->tags,
64
            'summary' => $this->summary,
65
            'description' => $this->description,
66
            'parameters' => $parameters,
67
            'responses' => $responses,
68
        ];
69
    }
70
}
71