Completed
Push — master ( 1f3fa8...7d4b61 )
by Mike
03:08
created

DataProviderPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 15
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Sugarcrm\UpgradeSpec\DI\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\Reference;
8
9 View Code Duplication
class DataProviderPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @param ContainerBuilder $container
13
     */
14
    public function process(ContainerBuilder $container)
15
    {
16
        if (!$container->has('data.provider_chain')) {
17
            return;
18
        }
19
20
        $providerChain = $container->findDefinition('data.provider_chain');
21
22
        $taggedProviders = $container->findTaggedServiceIds('data.provider');
23
        $providers = array_map(function ($id) {
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
24
            return new Reference($id);
25
        }, array_keys($taggedProviders));
26
27
        $providerChain->addMethodCall('addProviders', [$providers]);
28
    }
29
}
30