GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#14)
by
unknown
12:52
created

CompilerPass   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 77
Duplicated Lines 62.34 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 4
Bugs 0 Features 3
Metric Value
wmc 14
c 4
b 0
f 3
lcom 1
cbo 3
dl 48
loc 77
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 7 1
A loadFormlyFields() 15 15 4
A loadDataProviders() 11 11 3
A loadSubscribers() 11 11 3
A loadHelpMessageProviders() 11 11 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Linio\DynamicFormBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class CompilerPass implements CompilerPassInterface
10
{
11
    /**
12
     * @param ContainerBuilder $container
13
     */
14
    public function process(ContainerBuilder $container)
15
    {
16
        $this->loadFormlyFields($container);
17
        $this->loadDataProviders($container);
18
        $this->loadSubscribers($container);
19
        $this->loadHelpMessageProviders($container);
20
    }
21
22
    /**
23
     * @param ContainerBuilder $container
24
     */
25 View Code Duplication
    public function loadFormlyFields(ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method 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...
26
    {
27
        if (!$container->hasDefinition('container.formly_field')) {
28
            return;
29
        }
30
31
        $containerDefinition = $container->getDefinition('container.formly_field');
32
        $taggedServices = $container->findTaggedServiceIds('formly_field');
33
34
        foreach ($taggedServices as $id => $tags) {
35
            foreach ($tags as $attributes) {
36
                $containerDefinition->addMethodCall('addFormlyField', [$attributes['alias'], new Reference($id)]);
37
            }
38
        }
39
    }
40
41
    /**
42
     * @param ContainerBuilder $container
43
     */
44 View Code Duplication
    public function loadDataProviders(ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method 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...
45
    {
46
        $containerDefinition = $container->getDefinition('dynamic_form.factory');
47
        $taggedServices = $container->findTaggedServiceIds('dynamic_form.data_provider');
48
49
        foreach ($taggedServices as $id => $tags) {
50
            foreach ($tags as $attributes) {
51
                $containerDefinition->addMethodCall('addDataProvider', [$attributes['alias'], new Reference($id)]);
52
            }
53
        }
54
    }
55
56
    /**
57
     * @param ContainerBuilder $container
58
     */
59 View Code Duplication
    public function loadSubscribers(ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method 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...
60
    {
61
        $containerDefinition = $container->getDefinition('dynamic_form.factory');
62
        $taggedServices = $container->findTaggedServiceIds('dynamic_form.event_subscriber');
63
64
        foreach ($taggedServices as $id => $tags) {
65
            foreach ($tags as $attributes) {
66
                $containerDefinition->addMethodCall('addEventSubscriber', [$attributes['form_name'], new Reference($id)]);
67
            }
68
        }
69
    }
70
71
    /**
72
     * @param ContainerBuilder $container
73
     */
74 View Code Duplication
    public function loadHelpMessageProviders(ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method 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...
75
    {
76
        $containerDefinition = $container->getDefinition('dynamic_form.factory');
77
        $taggedServices = $container->findTaggedServiceIds('dynamic_form.help_message_provider');
78
79
        foreach ($taggedServices as $id => $tags) {
80
            foreach ($tags as $attributes) {
81
                $containerDefinition->addMethodCall('addHelpMessageProvider', [$attributes['alias'], new Reference($id)]);
82
            }
83
        }
84
    }
85
}
86