Completed
Push — master ( bca24d...1b0d8b )
by John
03:18
created

Parameter::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the KleijnWeb\PhpApi\Descriptions package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
namespace KleijnWeb\PhpApi\Descriptions\Description;
9
10
use KleijnWeb\PhpApi\Descriptions\Description\Schema\Schema;
11
use KleijnWeb\PhpApi\Descriptions\Description\Visitor\VisiteeMixin;
12
13
/**
14
 * @author John Kleijn <[email protected]>
15
 */
16
class Parameter implements Element
17
{
18
    use VisiteeMixin;
19
20
    const IN_BODY = 'body';
21
    const IN_PATH = 'path';
22
    const IN_QUERY = 'query';
23
    const IN_HEADER = 'header';
24
25
    /**
26
     * @var string
27
     */
28
    protected $name;
29
30
    /**
31
     * @var bool
32
     */
33
    protected $required = false;
34
35
    /**
36
     * @var string|null
37
     */
38
    protected $collectionFormat;
39
40
    /**
41
     * @var Schema
42
     */
43
    protected $schema;
44
45
    /**
46
     * @var string
47
     */
48
    protected $in;
49
50
    /**
51
     * Parameter constructor.
52
     *
53
     * @param string $name
54
     * @param bool   $required
55
     * @param Schema $schema
56
     * @param string $in
57
     * @param string $collectionFormat
58
     */
59
    public function __construct(string $name, bool $required, Schema $schema, string $in, $collectionFormat = null)
60
    {
61
        $this->name             = $name;
62
        $this->collectionFormat = $collectionFormat;
63
        $this->schema           = $schema;
64
        $this->in               = $in;
65
        $this->required         = $required;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getName(): string
72
    {
73
        return $this->name;
74
    }
75
76
    /**
77
     * @return bool
78
     */
79
    public function isRequired(): bool
80
    {
81
        return $this->required;
82
    }
83
84
    /**
85
     * @return string|null
86
     */
87
    public function getCollectionFormat()
88
    {
89
        return $this->collectionFormat;
90
    }
91
92
    /**
93
     * @return Schema
94
     */
95
    public function getSchema(): Schema
96
    {
97
        return $this->schema;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getIn(): string
104
    {
105
        return $this->in;
106
    }
107
}
108