gewebe /
SyliusVATPlugin
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Gewebe\SyliusVATPlugin\Vat\Rates; |
||
| 6 | |||
| 7 | use Ibericode\Vat\Countries; |
||
| 8 | use Ibericode\Vat\Rates; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * European VAT rates and countries |
||
| 12 | */ |
||
| 13 | final class EuRates implements RatesInterface |
||
| 14 | { |
||
| 15 | private Countries $countries; |
||
| 16 | |||
| 17 | public function __construct(private Rates $rates) |
||
| 18 | { |
||
| 19 | $this->countries = new Countries(); |
||
| 20 | } |
||
| 21 | |||
| 22 | public function getCountries(): array |
||
| 23 | { |
||
| 24 | $euCountries = []; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var string $countryCode |
||
| 28 | * @var string $countryName |
||
| 29 | */ |
||
| 30 | foreach ($this->countries as $countryCode => $countryName) { |
||
| 31 | if (!$this->countries->isCountryCodeInEU($countryCode)) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 32 | continue; |
||
| 33 | } |
||
| 34 | |||
| 35 | $euCountries[$countryCode] = $countryName; |
||
| 36 | } |
||
| 37 | |||
| 38 | return $euCountries; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function getCountryRate(string $countryCode, string $level = self::RATE_STANDARD): float |
||
| 42 | { |
||
| 43 | return $this->rates->getRateForCountry($countryCode, $level); |
||
| 44 | } |
||
| 45 | } |
||
| 46 |