Total Complexity | 5 |
Total Lines | 43 |
Duplicated Lines | 100 % |
Changes | 0 |
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 |
||
7 | View Code Duplication | class CustomProviderConfigurator implements ProviderConfigurator |
|
|
|||
8 | { |
||
9 | public function buildConfiguration(NodeBuilder $node) |
||
10 | { |
||
11 | // @formatter:off |
||
12 | $node |
||
13 | ->scalarNode('provider_class') |
||
14 | ->info('The class name of your provider class (e.g. the one that extends AbstractProvider)') |
||
15 | ->defaultValue('Sludio\HelperBundle\Oauth\Client\Provider\Custom\Custom') |
||
16 | ->end() |
||
17 | ->scalarNode('client_class') |
||
18 | ->info('If you have a sub-class of OAuth2Client you want to use, add it here') |
||
19 | ->defaultValue('Sludio\HelperBundle\Oauth\Client\OAuth2Client') |
||
20 | ->end() |
||
21 | ->arrayNode('provider_options') |
||
22 | ->info('Other options to pass to your provider\'s constructor') |
||
23 | ->prototype('variable')->end() |
||
24 | ->end() |
||
25 | ; |
||
26 | // @formatter:on |
||
27 | } |
||
28 | |||
29 | public function getProviderClass(array $config) |
||
30 | { |
||
31 | return $config['provider_class']; |
||
32 | } |
||
33 | |||
34 | public function getProviderOptions(array $config) |
||
35 | { |
||
36 | return array_merge([ |
||
37 | 'client_id' => $config['client_id'], |
||
38 | 'client_secret' => $config['client_secret'], |
||
39 | ], $config['provider_options']); |
||
40 | } |
||
41 | |||
42 | public function getProviderDisplayName() |
||
45 | } |
||
46 | |||
47 | public function getClientClass(array $config) |
||
50 | } |
||
51 | } |
||
52 |
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.