TTranslator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 43
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A injectTranslator() 0 4 1
A setTranslator() 0 4 1
A getTranslator() 0 8 2
1
<?php
2
/**
3
 * TTranslator.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        https://www.ipublikuj.eu
7
 * @author         Adam Kadlec <[email protected]>
8
 * @package        iPublikuj:Application!
9
 * @subpackage     UI
10
 * @since          1.0.0
11
 *
12
 * @date           05.02.15
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\Application\UI;
18
19
use Nette\Localization;
20
21
/**
22
 * Inject translator interface into presenters and components
23
 *
24
 * @package        iPublikuj:Application!
25
 * @subpackage     UI
26
 *
27
 * @author         Adam Kadlec <[email protected]>
28
 */
29 1
trait TTranslator
30
{
31
	/**
32
	 * @var Localization\ITranslator
33
	 */
34
	protected $translator;
35
36
	/**
37
	 * @param Localization\ITranslator $translator
38
	 *
39
	 * @return void
40
	 */
41
	public function injectTranslator(Localization\ITranslator $translator) : void
42
	{
43 1
		$this->translator = $translator;
44 1
	}
45
46
	/**
47
	 * Set translator service
48
	 *
49
	 * @param Localization\ITranslator $translator
50
	 * 
51
	 * @return void
52
	 */
53
	public function setTranslator(Localization\ITranslator $translator) : void
54
	{
55 1
		$this->translator = $translator;
56 1
	}
57
58
	/**
59
	 * Get app translator service
60
	 *
61
	 * @return Localization\ITranslator|NULL
62
	 */
63
	public function getTranslator() : ?Localization\ITranslator
64
	{
65 1
		if ($this->translator instanceof Localization\ITranslator) {
0 ignored issues
show
Bug introduced by
The class Nette\Localization\ITranslator does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
66 1
			return $this->translator;
67
		}
68
69
		return NULL;
70
	}
71
}
72