1 | <?php |
||
13 | final class AverageExchangeRateProvider implements ExchangeRateProviderInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var ExchangeRateProviderInterface[] |
||
17 | */ |
||
18 | private $exchangeRateProviders = []; |
||
19 | |||
20 | /** |
||
21 | * @var float |
||
22 | */ |
||
23 | private $tolerance; |
||
24 | |||
25 | /** |
||
26 | * @var ExchangeRateFactoryInterface |
||
27 | */ |
||
28 | private $exchangeRateFactory; |
||
29 | |||
30 | /** |
||
31 | * AverageExchangeRateProvider constructor. |
||
32 | * @param float|null $tolerance |
||
33 | * @param ExchangeRateFactoryInterface|null $exchangeRateFactory |
||
34 | */ |
||
35 | public function __construct(float $tolerance = null, ExchangeRateFactoryInterface $exchangeRateFactory = null) |
||
40 | |||
41 | /** |
||
42 | * @param ExchangeRateProviderInterface[] ...$exchangeRateProviders |
||
43 | * @return AverageExchangeRateProvider |
||
44 | */ |
||
45 | public function withProviders(ExchangeRateProviderInterface ...$exchangeRateProviders): self |
||
53 | |||
54 | /** |
||
55 | * @inheritDoc |
||
56 | */ |
||
57 | public function getExchangeRate(CurrencyInterface $sourceCurrency, CurrencyInterface $targetCurrency, DateTimeInterface $date = null): ExchangeRateInterface |
||
76 | |||
77 | /** |
||
78 | * @param ExchangeRateInterface[] ...$exchangeRates |
||
79 | * @throws \RuntimeException |
||
80 | */ |
||
81 | private function validate(ExchangeRateInterface ...$exchangeRates): void |
||
95 | |||
96 | /** |
||
97 | * @param array $array |
||
98 | * @return float |
||
99 | */ |
||
100 | private static function getAverageRatio(ExchangeRateInterface ...$exchangeRates): float |
||
111 | |||
112 | /** |
||
113 | * @param float|null $tolerance |
||
114 | * @param ExchangeRateFactoryInterface|null $exchangeRateFactory |
||
115 | * @return AverageExchangeRateProvider |
||
116 | */ |
||
117 | public static function create(float $tolerance = null, ExchangeRateFactoryInterface $exchangeRateFactory = null): self |
||
121 | } |
||
122 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.