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

TranslatorTrait::trans()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 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