Issues (2)

src/Vat/Rates/EuRates.php (1 issue)

Labels
Severity
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
It seems like $countryCode can also be of type null; however, parameter $code of Ibericode\Vat\Countries::isCountryCodeInEU() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
            if (!$this->countries->isCountryCodeInEU(/** @scrutinizer ignore-type */ $countryCode)) {
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