Completed
Pull Request — master (#1)
by Sascha-Oliver
07:20 queued 05:24
created

TranslationAdapterPhraseAppExtension::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 0
cts 15
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Translation\PlatformAdapter\PhraseApp\Bridge\Symfony\DependencyInjection;
4
5
use nediam\PhraseApp\PhraseAppClient;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8
use Translation\PlatformAdapter\PhraseApp\Bridge\Symfony\XliffFileDumper;
9
use Translation\PlatformAdapter\PhraseApp\PhraseApp;
10
11
class TranslationAdapterPhraseAppExtension extends Extension
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function load(array $configs, ContainerBuilder $container)
17
    {
18
        $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...
19
        $config = $this->processConfiguration($configuration, $configs);
20
21
        $container->setParameter('translation.dumper.xliff.class', XliffFileDumper::class);
22
23
        $apiDef = $container->register('php_translation.adapter.phrase_app.raw');
24
        $apiDef->setClass(PhraseAppClient::class);
25
        $apiDef->addArgument($config['token']);
26
27
        $adapterDef = $container->register('php_translation.adapter.phrase_app');
28
        $adapterDef
29
            ->setClass(PhraseApp::class)
30
            ->addArgument($apiDef)
31
            ->addArgument($config['project_id'])
32
            ->addArgument($config['locale_to_id_mapping']);
33
    }
34
}
35