Completed
Push — master ( fcd315...e54b6a )
by John
02:20
created

Parameter::__construct()   B

Complexity

Conditions 8
Paths 96

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 7.7777
c 0
b 0
f 0
cc 8
eloc 14
nc 96
nop 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Parameter::getPattern() 0 4 1
A Parameter::getCollectionFormat() 0 4 1
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the KleijnWeb\ApiDescriptions 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\ApiDescriptions\Description;
9
10
use KleijnWeb\ApiDescriptions\Description\Visitor\VisiteeMixin;
11
12
/**
13
 * @author John Kleijn <[email protected]>
14
 */
15
abstract class Parameter implements Element
16
{
17
    use VisiteeMixin;
18
19
    const IN_BODY = 'body';
20
    const IN_PATH = 'path';
21
    const IN_QUERY = 'query';
22
    const IN_HEADER = 'header';
23
24
    /**
25
     * @var string
26
     */
27
    protected $name;
28
29
    /**
30
     * @var string
31
     */
32
    protected $collectionFormat;
33
34
    /**
35
     * @var Schema
36
     */
37
    protected $schema;
38
39
    /**
40
     * @var bool
41
     */
42
    protected $required = false;
43
44
    /**
45
     * @var string
46
     */
47
    protected $in;
48
49
    /**
50
     * @var string|null
51
     */
52
    protected $enum;
53
54
    /**
55
     * @var string|null
56
     */
57
    protected $pattern;
58
59
    /**
60
     * @return string|null
61
     */
62
    public function getEnum()
63
    {
64
        return $this->enum;
65
    }
66
67
    /**
68
     * @return string|null
69
     */
70
    public function getPattern()
71
    {
72
        return $this->pattern;
73
    }
74
75
    /**
76
     * @return string|null
77
     */
78
    public function getCollectionFormat()
79
    {
80
        return $this->collectionFormat;
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getIn(): string
87
    {
88
        return $this->in;
89
    }
90
91
    /**
92
     * @return bool
93
     */
94
    public function isRequired(): bool
95
    {
96
        return $this->required;
97
    }
98
99
    /**
100
     * @return Schema
101
     */
102
    public function getSchema(): Schema
103
    {
104
        return $this->schema;
105
    }
106
107
    /**
108
     * @return string
109
     */
110
    public function getName(): string
111
    {
112
        return $this->name;
113
    }
114
115
    /**
116
     * @param string $location
117
     *
118
     * @return bool
119
     */
120
    public function isIn(string $location): bool
121
    {
122
        return $this->in === $location;
123
    }
124
}
125