|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace h4kuna\Exchange; |
|
4
|
|
|
|
|
5
|
|
|
use h4kuna\Number; |
|
6
|
|
|
|
|
7
|
|
|
class Filters |
|
8
|
|
|
{ |
|
9
|
|
|
|
|
10
|
|
|
/** @var Exchange */ |
|
11
|
|
|
private $exchange; |
|
12
|
|
|
|
|
13
|
|
|
/** @var Currency\Formats */ |
|
14
|
|
|
private $formats; |
|
15
|
|
|
|
|
16
|
|
|
/** @var Number\Tax */ |
|
17
|
|
|
private $vat; |
|
18
|
|
|
|
|
19
|
|
|
public function __construct(Exchange $exchange, Currency\Formats $formats) |
|
20
|
|
|
{ |
|
21
|
|
|
$this->exchange = $exchange; |
|
22
|
|
|
$this->formats = $formats; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param Number\Tax $vat |
|
27
|
|
|
*/ |
|
28
|
|
|
public function setVat(Number\Tax $vat) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->vat = $vat; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function change($number, $from = NULL, $to = NULL) |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->exchange->change($number, $from, $to); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function changeTo($number, $to = NULL) |
|
39
|
|
|
{ |
|
40
|
|
|
return $this->change($number, NULL, $to); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Count and format number. |
|
45
|
|
|
* @param number $number |
|
46
|
|
|
* @param string|NULL |
|
47
|
|
|
* @param string $to output currency, NULL set actual |
|
48
|
|
|
* @return string |
|
49
|
|
|
*/ |
|
50
|
|
|
public function format($number, $from = NULL, $to = NULL) |
|
51
|
|
|
{ |
|
52
|
|
|
$data = $this->exchange->transfer($number, $from, $to); |
|
53
|
|
|
return $this->formats->getFormat($data[1]->code)->format($data[0], $data[1]->code); |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param float $number |
|
58
|
|
|
* @param string $to |
|
59
|
|
|
* @return string |
|
60
|
|
|
*/ |
|
61
|
|
|
public function formatTo($number, $to) |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->format($number, NULL, $to); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param float|int $number |
|
68
|
|
|
* @return float |
|
69
|
|
|
*/ |
|
70
|
|
|
public function vat($number) |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->vat->add($number); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param float|int $number |
|
77
|
|
|
* @param string|NULL $from |
|
78
|
|
|
* @param string|NULL $to |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
|
|
public function formatVat($number, $from = NULL, $to = NULL) |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->format($this->vat($number), $from, $to); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @param float|int $number |
|
88
|
|
|
* @param string|NULL $to |
|
89
|
|
|
* @return string |
|
90
|
|
|
*/ |
|
91
|
|
|
public function formatVatTo($number, $to) |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->formatVat($number, NULL, $to); |
|
94
|
|
|
} |
|
95
|
|
|
} |
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
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.