Completed
Push — master ( 664709...70cc89 )
by Adam
05:40
created

DefaultPhraseAdapter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 53.85%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 61
ccs 7
cts 13
cp 0.5385
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A translate() 0 4 1
A setMessage() 0 4 1
A setCount() 0 4 1
A setParameters() 0 4 1
1
<?php
2
/**
3
 * DefaultPhraseAdapter.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec http://www.ipublikuj.eu
8
 * @package        iPublikuj:FlashMessages!
9
 * @subpackage     Adapters
10
 * @since          1.0.0
11
 *
12
 * @date           06.02.15
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\FlashMessages\Adapters;
18
19
use Nette;
20
use Nette\Localization;
21
22
/**
23
 * Default translator phrase adapter
24
 *
25
 * @package        iPublikuj:FlashMessages!
26
 * @subpackage     Adapters
27
 *
28
 * @author         Adam Kadlec <[email protected]>
29
 */
30 1
class DefaultPhraseAdapter extends Nette\Object implements IPhraseAdapter
31
{
32
	/**
33
	 * @var string
34
	 */
35
	private $message;
36
37
	/**
38
	 * @var int
39
	 */
40
	private $count;
41
42
	/**
43
	 * @var array
44
	 */
45
	private $parameters;
46
47
	/**
48
	 * @param string $message
49
	 * @param int $count
50
	 * @param array $parameters
51
	 */
52
	public function __construct($message, $count, $parameters = [])
53
	{
54 1
		$this->parameters = $parameters;
55 1
		$this->count = $count;
56 1
		$this->message = $message;
57 1
	}
58
59
	/**
60
	 * {@inheritdoc}
61
	 */
62
	public function translate(Localization\ITranslator $translator)
63
	{
64 1
		return $translator->translate($this->message, $this->count, $this->parameters);
0 ignored issues
show
Unused Code introduced by
The call to ITranslator::translate() has too many arguments starting with $this->parameters.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
65
	}
66
67
	/**
68
	 * {@inheritdoc}
69
	 */
70
	public function setMessage($message)
71
	{
72
		$this->message = $message;
73
	}
74
75
	/**
76
	 * {@inheritdoc}
77
	 */
78
	public function setCount($count)
79
	{
80
		$this->count = $count;
81
	}
82
83
	/**
84
	 * {@inheritdoc}
85
	 */
86
	public function setParameters($parameters)
87
	{
88
		$this->parameters = $parameters;
89
	}
90
}
91