Completed
Push — master ( 269a50...019c60 )
by Tobias
04:32
created

ContainerAwareTrans   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 52
rs 10
1
<?php
2
3
namespace Translation\Extractor\Tests\Resources\Php\Symfony;
4
5
use Symfony\Component\Translation\TranslatorInterface;
6
7
class ContainerAwareTrans
8
{
9
    private $translator;
10
11
    public function __construct(TranslatorInterface $translator)
12
    {
13
        $this->translator = $translator;
14
    }
15
16
    /**
17
     * @return array
18
     */
19
    public function newAction()
20
    {
21
        // Using container
22
        $translated = $this->get('translator')->trans('trans0');
23
24
        // As a parameter
25
        $model->setMessage(
26
            $this->get('translator')->trans(
27
                'trans1',
28
                array(
29
                    'a' => 'x',
30
                    'b' => 'y',
31
                    'c' => 'z',
32
                )
33
            )
34
        );
35
36
        return array();
37
    }
38
39
    public function getLine()
40
    {
41
        return $this->translator->trans('trans_line');
42
    }
43
    public function getTranslatorVariable()
44
    {
45
        $translator = $this->get('translator');
46
        $translator->trans('variable');
47
    }
48
49
    public function getPdfFilename(string $locale)
50
    {
51
        return $this->translator->trans('my.pdf', [], 'generic', $locale);
52
    }
53
54
    public function static()
55
    {
56
        $translator = static::$container->get('translator'); $foo = $translator->trans('bar');
57
    }
58
}
59