• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 13175309672

06 Feb 2025 09:04AM UTC coverage: 7.663% (-0.2%) from 7.841%
13175309672

push

github

web-flow
fix: ensure template files have a tpl file extension (#6826) (#6829)

2 of 5 new or added lines in 4 files covered. (40.0%)

3676 existing lines in 122 files now uncovered.

13073 of 170593 relevant lines covered (7.66%)

27.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.49
/src/Metadata/Parameter.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Metadata;
15

16
use ApiPlatform\OpenApi\Model\Parameter as OpenApiParameter;
17
use ApiPlatform\State\ParameterNotFound;
18
use ApiPlatform\State\ParameterProviderInterface;
19

20
/**
21
 * @experimental
22
 */
23
abstract class Parameter
24
{
25
    /**
26
     * @param (array<string, mixed>&array{type?: string, default?: string})|null $schema
27
     * @param array<string, mixed>                                               $extraProperties
28
     * @param ParameterProviderInterface|callable|string|null                    $provider
29
     * @param FilterInterface|string|null                                        $filter
30
     * @param mixed                                                              $constraints     an array of Symfony constraints, or an array of Laravel rules
31
     */
32
    public function __construct(
33
        protected ?string $key = null,
34
        protected ?array $schema = null,
35
        protected OpenApiParameter|array|false|null $openApi = null,
36
        protected mixed $provider = null,
37
        protected mixed $filter = null,
38
        protected ?string $property = null,
39
        protected ?string $description = null,
40
        protected ?bool $required = null,
41
        protected ?int $priority = null,
42
        protected ?false $hydra = null,
43
        protected mixed $constraints = null,
44
        protected string|\Stringable|null $security = null,
45
        protected ?string $securityMessage = null,
46
        protected ?array $extraProperties = [],
47
        protected ?array $filterContext = null,
48
    ) {
49
    }
226✔
50

51
    public function getKey(): ?string
52
    {
53
        return $this->key;
1,261✔
54
    }
55

56
    /**
57
     * @return (array<string, mixed>&array{type?: string, default?: string})|null $schema
58
     */
59
    public function getSchema(): ?array
60
    {
61
        return $this->schema;
916✔
62
    }
63

64
    /**
65
     * @return OpenApiParameter[]|OpenApiParameter|bool|null
66
     */
67
    public function getOpenApi(): OpenApiParameter|array|bool|null
68
    {
69
        return $this->openApi;
106✔
70
    }
71

72
    public function getProvider(): mixed
73
    {
74
        return $this->provider;
755✔
75
    }
76

77
    public function getProperty(): ?string
78
    {
79
        return $this->property;
611✔
80
    }
81

82
    public function getFilter(): mixed
83
    {
84
        return $this->filter;
1,025✔
85
    }
86

87
    public function getDescription(): ?string
88
    {
89
        return $this->description;
60✔
90
    }
91

92
    public function getRequired(): ?bool
93
    {
94
        return $this->required;
505✔
95
    }
96

97
    public function getPriority(): ?int
98
    {
99
        return $this->priority;
22✔
100
    }
101

102
    public function getHydra(): ?bool
103
    {
104
        return $this->hydra;
343✔
105
    }
106

107
    public function getConstraints(): mixed
108
    {
109
        return $this->constraints;
853✔
110
    }
111

112
    public function getSecurity(): string|\Stringable|null
113
    {
114
        return $this->security;
782✔
115
    }
116

117
    public function getSecurityMessage(): ?string
118
    {
119
        return $this->securityMessage;
30✔
120
    }
121

122
    /**
123
     * The computed value of this parameter, located into extraProperties['_api_values'].
124
     */
125
    public function getValue(mixed $default = new ParameterNotFound()): mixed
126
    {
127
        return $this->extraProperties['_api_values'] ?? $default;
906✔
128
    }
129

130
    /**
131
     * @return array<string, mixed>
132
     */
133
    public function getExtraProperties(): array
134
    {
135
        return $this->extraProperties;
852✔
136
    }
137

138
    public function getFilterContext(): ?array
139
    {
140
        return $this->filterContext;
3✔
141
    }
142

143
    public function withKey(string $key): static
144
    {
145
        $self = clone $this;
22✔
146
        $self->key = $key;
22✔
147

148
        return $self;
22✔
149
    }
150

151
    public function withPriority(int $priority): static
152
    {
153
        $self = clone $this;
22✔
154
        $self->priority = $priority;
22✔
155

156
        return $self;
22✔
157
    }
158

159
    /**
160
     * @param array{type?: string} $schema
161
     */
162
    public function withSchema(array $schema): static
163
    {
164
        $self = clone $this;
6✔
165
        $self->schema = $schema;
6✔
166

167
        return $self;
6✔
168
    }
169

170
    /**
171
     * @param OpenApiParameter[]|OpenApiParameter|bool $openApi
172
     */
173
    public function withOpenApi(OpenApiParameter|array|bool $openApi): static
174
    {
175
        $self = clone $this;
6✔
176
        $self->openApi = $openApi;
6✔
177

178
        return $self;
6✔
179
    }
180

181
    /**
182
     * @param ParameterProviderInterface|string $provider
183
     */
184
    public function withProvider(mixed $provider): static
185
    {
186
        $self = clone $this;
6✔
187
        $self->provider = $provider;
6✔
188

189
        return $self;
6✔
190
    }
191

192
    /**
193
     * @param FilterInterface|string $filter
194
     */
195
    public function withFilter(mixed $filter): static
196
    {
UNCOV
197
        $self = clone $this;
×
UNCOV
198
        $self->filter = $filter;
×
199

200
        return $self;
×
201
    }
202

203
    public function withProperty(string $property): static
204
    {
205
        $self = clone $this;
13✔
206
        $self->property = $property;
13✔
207

208
        return $self;
13✔
209
    }
210

211
    public function withDescription(string $description): static
212
    {
UNCOV
213
        $self = clone $this;
×
UNCOV
214
        $self->description = $description;
×
215

216
        return $self;
×
217
    }
218

219
    public function withRequired(bool $required): static
220
    {
UNCOV
221
        $self = clone $this;
×
UNCOV
222
        $self->required = $required;
×
223

224
        return $self;
×
225
    }
226

227
    public function withHydra(false $hydra): static
228
    {
UNCOV
229
        $self = clone $this;
×
UNCOV
230
        $self->hydra = $hydra;
×
231

232
        return $self;
×
233
    }
234

235
    public function withConstraints(mixed $constraints): static
236
    {
237
        $self = clone $this;
25✔
238
        $self->constraints = $constraints;
25✔
239

240
        return $self;
25✔
241
    }
242

243
    public function withSecurity(string|\Stringable|null $security): self
244
    {
UNCOV
245
        $self = clone $this;
×
UNCOV
246
        $self->security = $security;
×
247

248
        return $self;
×
249
    }
250

251
    public function withSecurityMessage(?string $securityMessage): self
252
    {
UNCOV
253
        $self = clone $this;
×
UNCOV
254
        $self->securityMessage = $securityMessage;
×
255

256
        return $self;
×
257
    }
258

259
    /**
260
     * @param array<string, mixed> $extraProperties
261
     */
262
    public function withExtraProperties(array $extraProperties): static
263
    {
264
        $self = clone $this;
852✔
265
        $self->extraProperties = $extraProperties;
852✔
266

267
        return $self;
852✔
268
    }
269
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc