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

api-platform / core / 14400124412

11 Apr 2025 09:31AM UTC coverage: 8.488%. Remained the same
14400124412

push

github

web-flow
fix(metadata): parameter provider within filter (#7081)

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

126 existing lines in 12 files now uncovered.

13402 of 157890 relevant lines covered (8.49%)

22.86 hits per line

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

64.06
/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|string|null $filterContext = null,
48
    ) {
49
    }
164✔
50

51
    public function getKey(): ?string
52
    {
53
        return $this->key;
1,021✔
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;
792✔
62
    }
63

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

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

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

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

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

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

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

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

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

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

117
    public function getSecurityMessage(): ?string
118
    {
119
        return $this->securityMessage;
20✔
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;
776✔
128
    }
129

130
    public function setValue(mixed $value): static
131
    {
NEW
132
        $this->extraProperties['_api_values'] = $value;
×
133

NEW
134
        return $this;
×
135
    }
136

137
    /**
138
     * @return array<string, mixed>
139
     */
140
    public function getExtraProperties(): array
141
    {
142
        return $this->extraProperties;
1,018✔
143
    }
144

145
    public function getFilterContext(): array|string|null
146
    {
147
        return $this->filterContext;
154✔
148
    }
149

150
    public function withKey(string $key): static
151
    {
152
        $self = clone $this;
29✔
153
        $self->key = $key;
29✔
154

155
        return $self;
29✔
156
    }
157

158
    public function withPriority(int $priority): static
159
    {
160
        $self = clone $this;
29✔
161
        $self->priority = $priority;
29✔
162

163
        return $self;
29✔
164
    }
165

166
    /**
167
     * @param array{type?: string} $schema
168
     */
169
    public function withSchema(array $schema): static
170
    {
171
        $self = clone $this;
19✔
172
        $self->schema = $schema;
19✔
173

174
        return $self;
19✔
175
    }
176

177
    /**
178
     * @param OpenApiParameter[]|OpenApiParameter|bool $openApi
179
     */
180
    public function withOpenApi(OpenApiParameter|array|bool $openApi): static
181
    {
182
        $self = clone $this;
13✔
183
        $self->openApi = $openApi;
13✔
184

185
        return $self;
13✔
186
    }
187

188
    /**
189
     * @param ParameterProviderInterface|string $provider
190
     */
191
    public function withProvider(mixed $provider): static
192
    {
193
        $self = clone $this;
4✔
194
        $self->provider = $provider;
4✔
195

196
        return $self;
4✔
197
    }
198

199
    /**
200
     * @param FilterInterface|string $filter
201
     */
202
    public function withFilter(mixed $filter): static
203
    {
204
        $self = clone $this;
×
205
        $self->filter = $filter;
×
206

207
        return $self;
×
208
    }
209

210
    public function withFilterContext(array|string $filterContext): static
211
    {
212
        $self = clone $this;
×
213
        $self->filterContext = $filterContext;
×
214

215
        return $self;
×
216
    }
217

218
    public function withProperty(string $property): static
219
    {
220
        $self = clone $this;
21✔
221
        $self->property = $property;
21✔
222

223
        return $self;
21✔
224
    }
225

226
    public function withDescription(string $description): static
227
    {
228
        $self = clone $this;
×
229
        $self->description = $description;
×
230

231
        return $self;
×
232
    }
233

234
    public function withRequired(bool $required): static
235
    {
236
        $self = clone $this;
×
237
        $self->required = $required;
×
238

239
        return $self;
×
240
    }
241

242
    public function withHydra(false $hydra): static
243
    {
244
        $self = clone $this;
×
245
        $self->hydra = $hydra;
×
246

247
        return $self;
×
248
    }
249

250
    public function withConstraints(mixed $constraints): static
251
    {
252
        $self = clone $this;
25✔
253
        $self->constraints = $constraints;
25✔
254

255
        return $self;
25✔
256
    }
257

258
    public function withSecurity(string|\Stringable|null $security): static
259
    {
260
        $self = clone $this;
×
261
        $self->security = $security;
×
262

263
        return $self;
×
264
    }
265

266
    public function withSecurityMessage(?string $securityMessage): static
267
    {
268
        $self = clone $this;
×
269
        $self->securityMessage = $securityMessage;
×
270

271
        return $self;
×
272
    }
273

274
    /**
275
     * @param array<string, mixed> $extraProperties
276
     */
277
    public function withExtraProperties(array $extraProperties): static
278
    {
279
        $self = clone $this;
742✔
280
        $self->extraProperties = $extraProperties;
742✔
281

282
        return $self;
742✔
283
    }
284
}
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