Completed
Push — master ( ba30b6...904d28 )
by Christian
13:26
created

ApiDescription::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 17
rs 9.2
c 1
b 0
f 0
cc 4
eloc 10
nc 8
nop 1
1
<?php
2
3
/**
4
 * This file is part of tenside/core.
5
 *
6
 * (c) Christian Schiffler <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * This project is provided in good faith and hope to be usable by anyone.
12
 *
13
 * @package    tenside/core
14
 * @author     Christian Schiffler <[email protected]>
15
 * @copyright  2015 Christian Schiffler <[email protected]>
16
 * @license    https://github.com/tenside/core/blob/master/LICENSE MIT
17
 * @link       https://github.com/tenside/core
18
 * @filesource
19
 */
20
21
namespace Tenside\CoreBundle\Annotation;
22
23
use Symfony\Component\Routing\Route;
24
25
/**
26
 * Annotation for API results.
27
 *
28
 * @Annotation
29
 */
30
class ApiDescription
31
{
32
    /**
33
     * The request payload description.
34
     *
35
     * @var array
36
     */
37
    private $request = [];
38
39
    /**
40
     * The response description.
41
     *
42
     * @var array
43
     */
44
    private $response = [];
45
46
    /**
47
     * Link to another route and inherit the doc from it.
48
     *
49
     * @var string
50
     */
51
    private $link;
52
53
    /**
54
     * Create a new instance.
55
     *
56
     * @param array $options The values from the annotation.
57
     */
58
    public function __construct($options)
59
    {
60
        if (isset($options['request'])) {
61
            $this->request = (array) $options['request'];
62
            unset($options['request']);
63
        }
64
65
        if (isset($options['response'])) {
66
            $this->response = (array) $options['response'];
67
            unset($options['response']);
68
        }
69
70
        if (isset($options['link'])) {
71
            $this->link = $options['link'];
72
            unset($options['link']);
73
        }
74
    }
75
76
    /**
77
     * Retrieve the request.
78
     *
79
     * @return array
80
     */
81
    public function getRequest()
82
    {
83
        return $this->request;
84
    }
85
86
    /**
87
     * Retrieve the response.
88
     *
89
     * @return array
90
     */
91
    public function getResponse()
92
    {
93
        return $this->response;
94
    }
95
96
    /**
97
     * Retrieve the link.
98
     *
99
     * @return string
100
     */
101
    public function getLink()
102
    {
103
        return $this->link;
104
    }
105
}
106