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

Response   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 2
b 0
f 0
dl 0
loc 35
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 10 2
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({"ANNOTATION"})
18
 */
19
final class Response
20
{
21
22
    /**
23
     * @Required
24
     *
25
     * @var int
26
     */
27
    public $code;
28
29
    /**
30
     * @Required
31
     *
32
     * @var string
33
     */
34
    public $description;
35
36
    /**
37
     * @var array<Sunrise\Http\Router\OpenApi\Annotation\OpenApi\Content>
38
     */
39
    public $content = [];
40
41
    /**
42
     * @return array
43
     */
44
    public function toArray() : array
45
    {
46
        $content = [];
47
        foreach ($this->content as $value) {
48
            $content[$value->mediaType] = $value->toArray();
49
        }
50
51
        return [
52
            'description' => $this->description,
53
            'content' => $content,
54
        ];
55
    }
56
}
57