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

api-platform / core / 9838795518

08 Jul 2024 11:33AM UTC coverage: 64.239% (+0.07%) from 64.173%
9838795518

push

github

web-flow
Merge pull request #6459 from soyuka/main

Merge 3.4

154 of 179 new or added lines in 24 files covered. (86.03%)

36 existing lines in 12 files now uncovered.

11326 of 17631 relevant lines covered (64.24%)

68.24 hits per line

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

58.82
/src/Symfony/Validator/State/QueryParameterValidateProvider.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\Symfony\Validator\State;
15

16
use ApiPlatform\Doctrine\Orm\State\Options;
17
use ApiPlatform\Metadata\CollectionOperationInterface;
18
use ApiPlatform\Metadata\HttpOperation;
19
use ApiPlatform\Metadata\Operation;
20
use ApiPlatform\ParameterValidator\ParameterValidator;
21
use ApiPlatform\State\ProviderInterface;
22
use ApiPlatform\State\Util\RequestParser;
23

24
final class QueryParameterValidateProvider implements ProviderInterface
25
{
26
    public function __construct(private readonly ?ProviderInterface $decorated, private readonly ParameterValidator $parameterValidator)
27
    {
28
    }
420✔
29

30
    public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
31
    {
32
        if (
33
            !$operation instanceof HttpOperation
420✔
34
            || !($request = $context['request'] ?? null)
420✔
35
            || !$request->isMethodSafe()
420✔
36
            || 'GET' !== $request->getMethod()
420✔
37
        ) {
38
            return $this->decorated?->provide($operation, $uriVariables, $context);
12✔
39
        }
40

41
        if (!($operation->getExtraProperties()['use_legacy_parameter_validator'] ?? true)) {
408✔
42
            return $this->decorated?->provide($operation, $uriVariables, $context);
368✔
43
        }
44

45
        if (!($operation->getQueryParameterValidationEnabled() ?? true) || !$operation instanceof CollectionOperationInterface) {
40✔
46
            return $this->decorated?->provide($operation, $uriVariables, $context);
40✔
47
        }
48

UNCOV
49
        $queryString = RequestParser::getQueryString($request);
×
UNCOV
50
        $queryParameters = $queryString ? RequestParser::parseRequestParams($queryString) : [];
×
UNCOV
51
        $class = $operation->getClass();
×
UNCOV
52
        if (($options = $operation->getStateOptions()) && $options instanceof Options && $options->getEntityClass()) {
×
53
            $class = $options->getEntityClass();
×
54
        }
55

UNCOV
56
        $this->parameterValidator->validateFilters($class, $operation->getFilters() ?? [], $queryParameters);
×
57

UNCOV
58
        return $this->decorated?->provide($operation, $uriVariables, $context);
×
59
    }
60
}
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