Completed
Push — master ( 67388e...1397e0 )
by Sascha-Oliver
9s
created

TranslationAdapterPhraseAppExtension::load()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 0
cts 24
cp 0
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 22
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Translation\PlatformAdapter\PhraseApp\Bridge\Symfony\DependencyInjection;
4
5
use FAPI\PhraseApp\HttpClientConfigurator;
6
use FAPI\PhraseApp\PhraseAppClient;
7
use FAPI\PhraseApp\RequestBuilder;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Definition;
10
use Symfony\Component\DependencyInjection\Reference;
11
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
12
use Translation\PlatformAdapter\PhraseApp\PhraseApp;
13
14
/**
15
 * @author Sascha-Oliver Prolic <[email protected]>
16
 */
17
class TranslationAdapterPhraseAppExtension extends Extension
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function load(array $configs, ContainerBuilder $container)
23
    {
24
        $configuration = new Configuration($container);
0 ignored issues
show
Unused Code introduced by
The call to Configuration::__construct() has too many arguments starting with $container.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
25
        $config = $this->processConfiguration($configuration, $configs);
26
27
        $requestBuilder = (new Definition(RequestBuilder::class))
28
            ->addArgument(new Reference($config['httplug_message_factory']));
29
30
        $clientConfigurator = (new Definition(HttpClientConfigurator::class))
31
            ->addArgument($config['token'])
32
            ->addArgument(new Reference($config['httplug_client']))
33
            ->addArgument(new Reference($config['httplug_uri_factory']));
34
35
        $apiDef = $container->register('php_translation.adapter.loco.raw');
36
        $apiDef->setClass(PhraseAppClient::class)
37
            ->setFactory([PhraseAppClient::class, 'configure'])
38
            ->addArgument($clientConfigurator)
39
            ->addArgument(null)
40
            ->addArgument($requestBuilder);
41
42
        $adapterDef = $container->register('php_translation.adapter.phrase_app');
43
        $adapterDef
44
            ->setClass(PhraseApp::class)
45
            ->addArgument($apiDef)
46
            ->addArgument($config['project_id'])
47
            ->addArgument($config['locale_to_id_mapping'])
48
            ->addArgument($config['domains']);
49
    }
50
}
51