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

api-platform / core / 10884379752

16 Sep 2024 01:01PM UTC coverage: 7.281% (-0.4%) from 7.672%
10884379752

push

github

soyuka
Merge 3.4

0 of 100 new or added lines in 7 files covered. (0.0%)

5332 existing lines in 181 files now uncovered.

11994 of 164725 relevant lines covered (7.28%)

9.52 hits per line

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

67.8
/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;
17
use ApiPlatform\OpenApi\Model\Parameter as OpenApiParameter;
18
use ApiPlatform\State\ParameterNotFound;
19
use ApiPlatform\State\ParameterProviderInterface;
20
use Symfony\Component\Validator\Constraint;
21

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

53
    public function getKey(): ?string
54
    {
UNCOV
55
        return $this->key;
393✔
56
    }
57

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

66
    /**
67
     * @return OpenApi\Model\Parameter[]|OpenApi\Model\Parameter|bool|null
68
     */
69
    public function getOpenApi(): OpenApiParameter|array|bool|null
70
    {
UNCOV
71
        return $this->openApi;
15✔
72
    }
73

74
    public function getProvider(): mixed
75
    {
UNCOV
76
        return $this->provider;
217✔
77
    }
78

79
    public function getProperty(): ?string
80
    {
UNCOV
81
        return $this->property;
183✔
82
    }
83

84
    public function getFilter(): mixed
85
    {
UNCOV
86
        return $this->filter;
323✔
87
    }
88

89
    public function getDescription(): ?string
90
    {
UNCOV
91
        return $this->description;
14✔
92
    }
93

94
    public function getRequired(): ?bool
95
    {
UNCOV
96
        return $this->required;
158✔
97
    }
98

99
    public function getPriority(): ?int
100
    {
UNCOV
101
        return $this->priority;
1✔
102
    }
103

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

109
    /**
110
     * @return Constraint|string|array<string, string>|Constraint[]|null
111
     */
112
    public function getConstraints(): Constraint|string|array|null
113
    {
UNCOV
114
        return $this->constraints;
250✔
115
    }
116

117
    public function getSecurity(): string|\Stringable|null
118
    {
UNCOV
119
        return $this->security;
241✔
120
    }
121

122
    public function getSecurityMessage(): ?string
123
    {
UNCOV
124
        return $this->securityMessage;
5✔
125
    }
126

127
    /**
128
     * The computed value of this parameter, located into extraProperties['_api_values'].
129
     *
130
     * @readonly
131
     */
132
    public function getValue(): mixed
133
    {
UNCOV
134
        return $this->extraProperties['_api_values'] ?? new ParameterNotFound();
270✔
135
    }
136

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

145
    public function getFilterContext(): ?array
146
    {
147
        return $this->filterContext;
×
148
    }
149

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

UNCOV
155
        return $self;
1✔
156
    }
157

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

UNCOV
163
        return $self;
1✔
164
    }
165

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

UNCOV
174
        return $self;
1✔
175
    }
176

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

UNCOV
185
        return $self;
1✔
186
    }
187

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

UNCOV
196
        return $self;
1✔
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 withProperty(string $property): static
211
    {
UNCOV
212
        $self = clone $this;
1✔
UNCOV
213
        $self->property = $property;
1✔
214

UNCOV
215
        return $self;
1✔
216
    }
217

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

223
        return $self;
×
224
    }
225

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

231
        return $self;
×
232
    }
233

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

239
        return $self;
×
240
    }
241

242
    /**
243
     * @param string|array<string, string>|Constraint[]|Constraint $constraints
244
     */
245
    public function withConstraints(string|array|Constraint $constraints): static
246
    {
UNCOV
247
        $self = clone $this;
7✔
UNCOV
248
        $self->constraints = $constraints;
7✔
249

UNCOV
250
        return $self;
7✔
251
    }
252

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

258
        return $self;
×
259
    }
260

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

266
        return $self;
×
267
    }
268

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

UNCOV
277
        return $self;
217✔
278
    }
279
}
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