Completed
Pull Request — master (#2)
by Tomáš
09:55
created

TTranslatorAware::getTranslator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SixtyEightPublishers\User\Common\Translator;
6
7
use Nette;
8
9
trait TTranslatorAware
10
{
11
	/** @var NULL|\Nette\Localization\ITranslator */
12
	private $translator;
13
14
	/**
15
	 * @param \Nette\Localization\ITranslator $translator
16
	 *
17
	 * @return void
18
	 */
19
	public function setTranslator(Nette\Localization\ITranslator $translator): void
20
	{
21
		$this->translator = $translator;
22
	}
23
24
	/**
25
	 * @return \Nette\Localization\ITranslator
26
	 */
27
	public function getTranslator(): Nette\Localization\ITranslator
28
	{
29
		if (NULL === $this->translator) {
30
			$this->translator = new NullTranslator();
31
		}
32
33
		return $this->translator;
34
	}
35
}
36