TranslatorTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 21
rs 10
c 1
b 1
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTranslator() 0 8 2
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