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

Response::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 9
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\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