TranslatorTrait::getTranslator()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Translation;
4
5
use Symfony\Component\DependencyInjection\ContainerInterface;
6
use Symfony\Component\Translation\TranslatorInterface;
7
8
trait TranslatorTrait
9
{
10
    /**
11
     * @var TranslatorInterface
12
     */
13
    private $translator;
14
15
    /**
16
     * @param ContainerInterface $container
17
     *
18
     * @return TranslatorInterface
19
     */
20
    private function getTranslator(ContainerInterface $container): TranslatorInterface
21
    {
22
        if (!$this->translator) {
23
            $this->translator = $container->get('translator');
24
        }
25
26
        return $this->translator;
27
    }
28
}
29