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

api-platform / core / 13587089462

28 Feb 2025 10:10AM UTC coverage: 8.516% (+0.02%) from 8.501%
13587089462

push

github

soyuka
Merge 4.1

5 of 11 new or added lines in 3 files covered. (45.45%)

5287 existing lines in 158 files now uncovered.

13370 of 157001 relevant lines covered (8.52%)

22.87 hits per line

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

66.13
/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
    ) {
UNCOV
49
    }
170✔
50

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

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

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

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

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

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

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

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

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

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

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

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

117
    public function getSecurityMessage(): ?string
118
    {
UNCOV
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
    {
UNCOV
127
        return $this->extraProperties['_api_values'] ?? $default;
772✔
128
    }
129

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

138
    public function getFilterContext(): array|string|null
139
    {
UNCOV
140
        return $this->filterContext;
154✔
141
    }
142

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

UNCOV
148
        return $self;
29✔
149
    }
150

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

UNCOV
156
        return $self;
29✔
157
    }
158

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

UNCOV
167
        return $self;
19✔
168
    }
169

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

UNCOV
178
        return $self;
13✔
179
    }
180

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

UNCOV
189
        return $self;
4✔
190
    }
191

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

200
        return $self;
×
201
    }
202

203
    public function withFilterContext(array|string $filterContext): static
204
    {
205
        $self = clone $this;
×
206
        $self->filterContext = $filterContext;
×
207

208
        return $self;
×
209
    }
210

211
    public function withProperty(string $property): static
212
    {
UNCOV
213
        $self = clone $this;
21✔
UNCOV
214
        $self->property = $property;
21✔
215

UNCOV
216
        return $self;
21✔
217
    }
218

219
    public function withDescription(string $description): static
220
    {
221
        $self = clone $this;
×
222
        $self->description = $description;
×
223

224
        return $self;
×
225
    }
226

227
    public function withRequired(bool $required): static
228
    {
229
        $self = clone $this;
×
230
        $self->required = $required;
×
231

232
        return $self;
×
233
    }
234

235
    public function withHydra(false $hydra): static
236
    {
237
        $self = clone $this;
×
238
        $self->hydra = $hydra;
×
239

240
        return $self;
×
241
    }
242

243
    public function withConstraints(mixed $constraints): static
244
    {
UNCOV
245
        $self = clone $this;
25✔
UNCOV
246
        $self->constraints = $constraints;
25✔
247

UNCOV
248
        return $self;
25✔
249
    }
250

251
    public function withSecurity(string|\Stringable|null $security): static
252
    {
253
        $self = clone $this;
×
254
        $self->security = $security;
×
255

256
        return $self;
×
257
    }
258

259
    public function withSecurityMessage(?string $securityMessage): static
260
    {
261
        $self = clone $this;
×
262
        $self->securityMessage = $securityMessage;
×
263

264
        return $self;
×
265
    }
266

267
    /**
268
     * @param array<string, mixed> $extraProperties
269
     */
270
    public function withExtraProperties(array $extraProperties): static
271
    {
UNCOV
272
        $self = clone $this;
738✔
UNCOV
273
        $self->extraProperties = $extraProperties;
738✔
274

UNCOV
275
        return $self;
738✔
276
    }
277
}
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