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

ReCaptchaConfigurator::configureClient()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 23
nc 1
nop 3
dl 0
loc 32
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Captcha\Configurator;
4
5
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
class ReCaptchaConfigurator implements CaptchaConfiguratorInterface
9
{
10
11
    public function buildConfiguration(NodeBuilder $node)
12
    {
13
        // @formatter:off
14
        $node
15
            ->scalarNode('public_key')->isRequired()->cannotBeEmpty()->end()
16
            ->scalarNode('private_key')->isRequired()->cannotBeEmpty()->end()
0 ignored issues
show
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

16
            ->/** @scrutinizer ignore-call */ scalarNode('private_key')->isRequired()->cannotBeEmpty()->end()

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\ArrayNodeDefinition. ( Ignorable by Annotation )

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

16
            ->/** @scrutinizer ignore-call */ scalarNode('private_key')->isRequired()->cannotBeEmpty()->end()

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...\VariableNodeDefinition. ( Ignorable by Annotation )

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

16
            ->/** @scrutinizer ignore-call */ scalarNode('private_key')->isRequired()->cannotBeEmpty()->end()

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

16
            ->/** @scrutinizer ignore-call */ scalarNode('private_key')->isRequired()->cannotBeEmpty()->end()
Loading history...
17
            ->booleanNode('verify_host')->defaultValue(false)->end()
0 ignored issues
show
Bug introduced by
The method booleanNode() 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 */ booleanNode('verify_host')->defaultValue(false)->end()
Loading history...
Bug introduced by
The method booleanNode() 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 */ booleanNode('verify_host')->defaultValue(false)->end()

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 booleanNode() 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 */ booleanNode('verify_host')->defaultValue(false)->end()

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 booleanNode() 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 */ booleanNode('verify_host')->defaultValue(false)->end()

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
            ->booleanNode('ajax')->defaultValue(false)->end()
19
            ->scalarNode('locale_key')->defaultValue('en')->end()
20
            ->booleanNode('locale_from_request')->defaultValue(false)->end()
21
            ->scalarNode('template')->defaultValue('SludioHelperBundle:Captcha:sludio_helper_captcha_recaptcha_widget.html.twig')->end()
22
            ->scalarNode('resolver_class')->defaultValue('Sludio\HelperBundle\Captcha\Router\LocaleResolver')->end()
23
            ->scalarNode('type_class')->defaultValue('Sludio\HelperBundle\Captcha\Form\Type\RecaptchaType')->end()
24
            ->scalarNode('validator_class')->defaultValue('Sludio\HelperBundle\Captcha\Validator\Constraint\IsTrueValidator')->end()
25
            ->arrayNode('http_proxy')
0 ignored issues
show
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

25
            ->/** @scrutinizer ignore-call */ arrayNode('http_proxy')

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

25
            ->/** @scrutinizer ignore-call */ arrayNode('http_proxy')
Loading history...
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

25
            ->/** @scrutinizer ignore-call */ arrayNode('http_proxy')

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

25
            ->/** @scrutinizer ignore-call */ arrayNode('http_proxy')

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
                ->addDefaultsIfNotSet()
27
                ->children()
28
                    ->scalarNode('host')->defaultValue(null)->end()
29
                    ->scalarNode('port')->defaultValue(null)->end()
30
                    ->scalarNode('auth')->defaultValue(null)->end()
31
                ->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

31
                ->/** @scrutinizer ignore-call */ end()
Loading history...
32
            ->end()
33
        ;
34
        // @formatter:on
35
    }
36
37
    public function configureClient(ContainerBuilder $container, $clientServiceKey, array $options = [])
38
    {
39
        /* RESOLVER */
40
        $resolver = $clientServiceKey.'.resolver';
41
        $resolverClass = $container->getParameter($clientServiceKey.'.resolver_class');
42
43
        $resolverDefinition = $container->register($resolver, $resolverClass);
44
        $resolverDefinition->setPublic(false);
45
        $resolverDefinition->setArguments([
46
            $container->getParameter($clientServiceKey.'.locale_key'),
47
            $container->getParameter($clientServiceKey.'.locale_from_request'),
48
        ]);
49
        /* TYPE */
50
        $type = $clientServiceKey.'.form.type';
51
        $typeClass = $container->getParameter($clientServiceKey.'.type_class');
52
        $typeDefinition = $container->register($type, $typeClass);
53
        $typeDefinition->setArguments([
54
            $container->getParameter($clientServiceKey.'.public_key'),
55
            $container->getParameter($clientServiceKey.'.ajax'),
56
            $container->getDefinition($resolver),
57
        ]);
58
        $typeDefinition->addTag('form.type');
59
        /* VALIDATOR */
60
        $validator = $clientServiceKey.'.validator.true';
61
        $validatorClass = $container->getParameter($clientServiceKey.'.validator_class');
62
        $validatorDefinition = $container->register($validator, $validatorClass);
63
        $validatorDefinition->setArguments([
64
            $container->getParameter($clientServiceKey.'.private_key'),
65
            $container->getParameter($clientServiceKey.'.http_proxy'),
66
            $container->getParameter($clientServiceKey.'.verify_host'),
67
        ]);
68
        $validatorDefinition->addTag('validator.constraint_validator');
69
    }
70
}