Passed
Push — master ( 8eea92...da79af )
by Dāvis
03:03
created

GoogleProviderConfigurator::buildConfiguration()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 25
nc 1
nop 1
dl 0
loc 28
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Oauth\Configurator;
4
5
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
6
7
class GoogleProviderConfigurator implements ProviderConfiguratorInterface
8
{
9
    public function buildConfiguration(NodeBuilder $node)
10
    {
11
        // @formatter:off
12
        $node
13
            ->scalarNode('access_type')
14
                ->defaultNull()
15
                ->info('Optional value for sending access_type parameter. More detail: https://developers.google.com/identity/protocols/OpenIDConnect#authenticationuriparameters')
16
            ->end()
17
            ->scalarNode('hosted_domain')
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('hosted_domain')

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('hosted_domain')
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('hosted_domain')

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('hosted_domain')

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
                ->defaultNull()
19
                ->info('Optional value for sending hd parameter. More detail: https://developers.google.com/identity/protocols/OpenIDConnect#hd-param')
20
            ->end()
21
            ->arrayNode('user_fields')
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('user_fields')

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('user_fields')

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('user_fields')

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('user_fields')
Loading history...
22
                ->prototype('scalar')->end()
23
                ->info('Optional value for additional fields to be requested from the user profile. If set, these values will be included with the defaults. More details: https://developers.google.com/+/web/api/rest/latest/people')
0 ignored issues
show
Bug introduced by
The method info() does not exist on 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

23
                ->/** @scrutinizer ignore-call */ info('Optional value for additional fields to be requested from the user profile. If set, these values will be included with the defaults. More details: https://developers.google.com/+/web/api/rest/latest/people')

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 info() 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...\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

23
                ->/** @scrutinizer ignore-call */ info('Optional value for additional fields to be requested from the user profile. If set, these values will be included with the defaults. More details: https://developers.google.com/+/web/api/rest/latest/people')
Loading history...
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
            ->scalarNode('client_class')
0 ignored issues
show
Bug introduced by
The method scalarNode() does not exist on Symfony\Component\Config...NodeDefinitionInterface. ( Ignorable by Annotation )

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

25
            ->/** @scrutinizer ignore-call */ scalarNode('client_class')

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...
26
                ->info('If you have a sub-class of OAuth2Client you want to use, add it here')
27
                ->defaultValue('Sludio\HelperBundle\Oauth\Client\Client\GoogleOAuth2Client')
28
            ->end()
29
            ->scalarNode('redirect_route')
30
                ->isRequired()
31
                ->cannotBeEmpty()
32
            ->end()
33
            ->arrayNode('provider_options')
34
                ->info('Other options to pass to your provider\'s constructor')
35
                ->prototype('variable')->end()
36
            ->end()
37
        ;
38
        // @formatter:on
39
    }
40
41
    public function getProviderClass(array $config)
42
    {
43
        return 'Sludio\HelperBundle\Oauth\Client\Provider\Google\Google';
44
    }
45
46
    public function getProviderOptions(array $config)
47
    {
48
        $options = [
49
            'clientId' => $config['client_id'],
50
            'clientSecret' => $config['client_secret'],
51
            'redirect_route' => $config['redirect_route'],
52
        ];
53
54
        if ($config['access_type']) {
55
            $options['accessType'] = $config['access_type'];
56
        }
57
58
        if ($config['hosted_domain']) {
59
            $options['hostedDomain'] = $config['hosted_domain'];
60
        }
61
62
        if (!empty($config['user_fields'])) {
63
            $options['userFields'] = $config['user_fields'];
64
        }
65
66
        return array_merge($options, $config['provider_options']);
67
    }
68
69
    public function getProviderDisplayName()
70
    {
71
        return 'Google';
72
    }
73
74
    public function getClientClass(array $config)
75
    {
76
        return $config['client_class'];
77
    }
78
}
79