Completed
Push — master ( 98955b...63d555 )
by Kévin
03:49
created

AbstractContextAwareFilter::apply()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 3
nop 5
1
<?php
2
3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <[email protected]>
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\Core\Bridge\Doctrine\Orm\Filter;
15
16
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
17
use Doctrine\ORM\QueryBuilder;
18
19
abstract class AbstractContextAwareFilter extends AbstractFilter implements ContextAwareFilterInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null, array $context = [])
25
    {
26
        if (!isset($context['filters']) || !\is_array($context['filters'])) {
27
            parent::apply($queryBuilder, $queryNameGenerator, $resourceClass, $operationName, $context);
0 ignored issues
show
Unused Code introduced by
The call to AbstractFilter::apply() has too many arguments starting with $context.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
28
29
            return;
30
        }
31
32
        foreach ($context['filters'] as $property => $value) {
33
            $this->filterProperty($property, $value, $queryBuilder, $queryNameGenerator, $resourceClass, $operationName, $context);
0 ignored issues
show
Unused Code introduced by
The call to AbstractContextAwareFilter::filterProperty() has too many arguments starting with $context.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
34
        }
35
    }
36
}
37