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

api-platform / core / 10014117656

19 Jul 2024 08:44PM UTC coverage: 7.856% (-56.3%) from 64.185%
10014117656

push

github

soyuka
Merge branch 'sf/remove-flag'

0 of 527 new or added lines in 83 files covered. (0.0%)

10505 existing lines in 362 files now uncovered.

12705 of 161727 relevant lines covered (7.86%)

26.85 hits per line

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

58.62
/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\State\ParameterNotFound;
18
use ApiPlatform\State\ParameterProviderInterface;
19
use Symfony\Component\Validator\Constraint;
20

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

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

64
    public function getOpenApi(): OpenApi\Model\Parameter|bool|null
65
    {
UNCOV
66
        return $this->openApi;
72✔
67
    }
68

69
    public function getProvider(): mixed
70
    {
UNCOV
71
        return $this->provider;
731✔
72
    }
73

74
    public function getProperty(): ?string
75
    {
UNCOV
76
        return $this->property;
96✔
77
    }
78

79
    public function getFilter(): mixed
80
    {
UNCOV
81
        return $this->filter;
969✔
82
    }
83

84
    public function getDescription(): ?string
85
    {
UNCOV
86
        return $this->description;
57✔
87
    }
88

89
    public function getRequired(): ?bool
90
    {
UNCOV
91
        return $this->required;
482✔
92
    }
93

94
    public function getPriority(): ?int
95
    {
UNCOV
96
        return $this->priority;
15✔
97
    }
98

99
    public function getHydra(): ?bool
100
    {
UNCOV
101
        return $this->hydra;
331✔
102
    }
103

104
    /**
105
     * @return Constraint|Constraint[]|null
106
     */
107
    public function getConstraints(): Constraint|array|null
108
    {
UNCOV
109
        return $this->constraints;
819✔
110
    }
111

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

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

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

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

140
    public function withKey(string $key): static
141
    {
UNCOV
142
        $self = clone $this;
15✔
UNCOV
143
        $self->key = $key;
15✔
144

UNCOV
145
        return $self;
15✔
146
    }
147

148
    public function withPriority(int $priority): static
149
    {
UNCOV
150
        $self = clone $this;
15✔
UNCOV
151
        $self->priority = $priority;
15✔
152

UNCOV
153
        return $self;
15✔
154
    }
155

156
    /**
157
     * @param array{type?: string} $schema
158
     */
159
    public function withSchema(array $schema): static
160
    {
161
        $self = clone $this;
×
162
        $self->schema = $schema;
×
163

164
        return $self;
×
165
    }
166

167
    public function withOpenApi(OpenApi\Model\Parameter $openApi): static
168
    {
169
        $self = clone $this;
×
170
        $self->openApi = $openApi;
×
171

172
        return $self;
×
173
    }
174

175
    /**
176
     * @param ParameterProviderInterface|string $provider
177
     */
178
    public function withProvider(mixed $provider): static
179
    {
UNCOV
180
        $self = clone $this;
6✔
UNCOV
181
        $self->provider = $provider;
6✔
182

UNCOV
183
        return $self;
6✔
184
    }
185

186
    /**
187
     * @param FilterInterface|string $filter
188
     */
189
    public function withFilter(mixed $filter): static
190
    {
191
        $self = clone $this;
×
192
        $self->filter = $filter;
×
193

194
        return $self;
×
195
    }
196

197
    public function withProperty(string $property): static
198
    {
UNCOV
199
        $self = clone $this;
6✔
UNCOV
200
        $self->property = $property;
6✔
201

UNCOV
202
        return $self;
6✔
203
    }
204

205
    public function withDescription(string $description): static
206
    {
207
        $self = clone $this;
×
208
        $self->description = $description;
×
209

210
        return $self;
×
211
    }
212

213
    public function withRequired(bool $required): static
214
    {
215
        $self = clone $this;
×
216
        $self->required = $required;
×
217

218
        return $self;
×
219
    }
220

221
    public function withHydra(false $hydra): static
222
    {
223
        $self = clone $this;
×
224
        $self->hydra = $hydra;
×
225

226
        return $self;
×
227
    }
228

229
    public function withConstraints(array|Constraint $constraints): static
230
    {
UNCOV
231
        $self = clone $this;
15✔
UNCOV
232
        $self->constraints = $constraints;
15✔
233

UNCOV
234
        return $self;
15✔
235
    }
236

237
    public function withSecurity(string|\Stringable|null $security): self
238
    {
239
        $self = clone $this;
×
240
        $self->security = $security;
×
241

242
        return $self;
×
243
    }
244

245
    public function withSecurityMessage(?string $securityMessage): self
246
    {
247
        $self = clone $this;
×
248
        $self->securityMessage = $securityMessage;
×
249

250
        return $self;
×
251
    }
252

253
    /**
254
     * @param array<string, mixed> $extraProperties
255
     */
256
    public function withExtraProperties(array $extraProperties): static
257
    {
UNCOV
258
        $self = clone $this;
728✔
UNCOV
259
        $self->extraProperties = $extraProperties;
728✔
260

UNCOV
261
        return $self;
728✔
262
    }
263
}
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