Passed
Branch master (c65ffc)
by Dāvis
03:08
created

DraugiemProviderConfigurator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
dl 44
loc 44
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A buildConfiguration() 16 16 1
A getClientClass() 3 3 1
A getProviderOptions() 7 7 1
A getProviderDisplayName() 3 3 1
A getProviderClass() 3 3 1

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 Sludio\HelperBundle\Oauth\Configurator;
4
5
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
6
7 View Code Duplication
class DraugiemProviderConfigurator implements ProviderConfigurator
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...
8
{
9
    public function buildConfiguration(NodeBuilder $node)
10
    {
11
        // @formatter:off
12
        $node
13
            ->scalarNode('client_class')
14
                ->info('If you have a sub-class of OAuth2Client you want to use, add it here')
15
                ->defaultValue('Sludio\HelperBundle\Oauth\Client\Client\DraugiemOAuth2Client')
16
            ->end()
17
            ->scalarNode('redirect_route')
0 ignored issues
show
Bug introduced by
The method scalarNode() does not exist on Symfony\Component\Config...\VariableNodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
            ->/** @scrutinizer ignore-call */ scalarNode('redirect_route')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method scalarNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
            ->/** @scrutinizer ignore-call */ scalarNode('redirect_route')
Loading history...
Bug introduced by
The method scalarNode() does not exist on Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
            ->/** @scrutinizer ignore-call */ scalarNode('redirect_route')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method scalarNode() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
            ->/** @scrutinizer ignore-call */ scalarNode('redirect_route')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
18
                ->isRequired()
19
                ->cannotBeEmpty()
20
            ->end()
21
            ->arrayNode('provider_options')
0 ignored issues
show
Bug introduced by
The method arrayNode() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
            ->/** @scrutinizer ignore-call */ arrayNode('provider_options')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method arrayNode() does not exist on Symfony\Component\Config...\VariableNodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
            ->/** @scrutinizer ignore-call */ arrayNode('provider_options')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method arrayNode() does not exist on Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
            ->/** @scrutinizer ignore-call */ arrayNode('provider_options')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method arrayNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
            ->/** @scrutinizer ignore-call */ arrayNode('provider_options')
Loading history...
22
                ->info('Other options to pass to your provider\'s constructor')
23
                ->prototype('variable')->end()
24
            ->end()
0 ignored issues
show
Bug introduced by
The method end() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
            ->/** @scrutinizer ignore-call */ end()
Loading history...
25
        ;
26
        // @formatter:on
27
    }
28
29
    public function getProviderClass(array $config)
30
    {
31
        return 'Sludio\HelperBundle\Oauth\Client\Provider\Draugiem\Draugiem';
32
    }
33
34
    public function getProviderOptions(array $config)
35
    {
36
        return array_merge([
37
            'clientId' => $config['client_id'],
38
            'clientSecret' => $config['client_secret'],
39
            'redirect_route' => $config['redirect_route'],
40
        ], $config['provider_options']);
41
    }
42
43
    public function getProviderDisplayName()
44
    {
45
        return 'Draugiem.lv';
46
    }
47
48
    public function getClientClass(array $config)
49
    {
50
        return $config['client_class'];
51
    }
52
}
53