Completed
Push — master ( fd7370...afa46a )
by Joachim
04:42
created

TranslatorTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
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\Translation\IdentityTranslator;
6
7
trait TranslatorTrait
8
{
9
    /**
10
     * @var IdentityTranslator
11
     */
12
    private $translator;
13
14
    /**
15
     * @return IdentityTranslator
16
     */
17
    private function getTranslator() : IdentityTranslator
18
    {
19
        if (!$this->translator) {
20
            $this->translator = $this->container->get('translator');
0 ignored issues
show
Bug introduced by
The property container does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
21
        }
22
23
        return $this->translator;
24
    }
25
}
26