Completed
Pull Request — master (#917)
by Dmitry
08:52
created

RequestCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 0
cts 9
cp 0
rs 9.4285
cc 3
eloc 9
nc 3
nop 1
crap 12
1
<?php
2
3
/**
4
 * This file is part of the FOSElasticaBundle project.
5
 *
6
 * (c) Tim Nagel <[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
namespace FOS\ElasticaBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\ContainerInterface;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
final class RequestCompilerPass implements CompilerPassInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function process(ContainerBuilder $container)
25
    {
26
        if (!$container->hasDefinition('fos_elastica.paginator.subscriber')) {
27
            return;
28
        }
29
30
        $definition = $container->getDefinition('fos_elastica.paginator.subscriber');
31
        if ($container->hasDefinition('request_stack')) {
32
            $arguments = array(new Reference('request_stack', ContainerInterface::NULL_ON_INVALID_REFERENCE, false));
0 ignored issues
show
Unused Code introduced by
The call to Reference::__construct() has too many arguments starting with false.

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...
33
        } else {
34
            $arguments = array(new Reference('request', ContainerInterface::NULL_ON_INVALID_REFERENCE, false));
0 ignored issues
show
Unused Code introduced by
The call to Reference::__construct() has too many arguments starting with false.

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...
35
        }
36
37
        $definition->addMethodCall('setRequest', $arguments);
38
    }
39
}
40