* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Adapter\Country; use PrestaShop\PrestaShop\Core\Country\CountryRequiredFieldsProviderInterface; use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryNotFoundException; use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; class CountryRequiredFieldsProvider implements CountryRequiredFieldsProviderInterface { /** * @var CountryDataProvider */ private $countryDataProvider; public function __construct(CountryDataProvider $countryDataProvider) { $this->countryDataProvider = $countryDataProvider; } /** * {@inheritdoc} * * @throws CountryNotFoundException */ public function isStatesRequired(CountryId $countryId): bool { $countries = $this->countryDataProvider->getCountriesIdWhichNeedState(); return in_array($countryId->getValue(), $countries); } /** * {@inheritdoc} * * @throws CountryNotFoundException */ public function isDniRequired(CountryId $countryId): bool { $countries = $this->countryDataProvider->getCountriesIdWhichNeedDni(); return in_array($countryId->getValue(), $countries); } }