Completed
Push — master ( 35bfed...a5f27e )
by Adam
05:07
created

DefaultPhraseAdapter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 2
dl 0
loc 61
ccs 6
cts 12
cp 0.5
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setMessage() 0 4 1
A setCount() 0 4 1
A setParameters() 0 4 1
A translate() 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
namespace IPub\FlashMessages\Adapters;
16
17
use Nette;
18
use Nette\Localization;
19
20
/**
21
 * Default translator phrase adapter
22
 *
23
 * @package        iPublikuj:FlashMessages!
24
 * @subpackage     Adapters
25
 *
26
 * @author         Adam Kadlec <[email protected]>
27
 */
28 1
class DefaultPhraseAdapter extends Nette\Object implements IPhraseAdapter
29
{
30
	/**
31
	 * @var string
32
	 */
33
	protected $message;
34
35
	/**
36
	 * @var int
37
	 */
38
	protected $count;
39
40
	/**
41
	 * @var array
42
	 */
43
	protected $parameters;
44
45
	/**
46
	 * @param string $message
47
	 * @param int $count
48
	 * @param array $parameters
49
	 */
50
	public function __construct($message, $count, $parameters = [])
51
	{
52 1
		$this->parameters = $parameters;
53 1
		$this->count = $count;
54 1
		$this->message = $message;
55 1
	}
56
57
	/**
58
	 * {@inheritdoc}
59
	 */
60
	public function translate(Localization\ITranslator $translator)
61
	{
62 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...
63
	}
64
65
	/**
66
	 * {@inheritdoc}
67
	 */
68
	public function setMessage($message)
69
	{
70
		$this->message = $message;
71
	}
72
73
	/**
74
	 * {@inheritdoc}
75
	 */
76
	public function setCount($count)
77
	{
78
		$this->count = $count;
79
	}
80
81
	/**
82
	 * {@inheritdoc}
83
	 */
84
	public function setParameters($parameters)
85
	{
86
		$this->parameters = $parameters;
87
	}
88
}
89