mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 23:59:51 +01:00
This change will bring many breaking changes. The good thing is that we can finally use more modern resources available in PHP. I can imagine that's not a popular change since it will bring many breaking changes to users, but we shouldn't be stuck in time because of that. Using some of those features will make it easier to contribute to the project. At least, I hope so. There are still some useless doc-blocks, and we're not using "readonly" properties when we could. I aim to send those changes soon. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
44 lines
917 B
PHP
44 lines
917 B
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
use Respect\Validation\Helpers\CountryInfo;
|
|
|
|
use function array_keys;
|
|
|
|
/**
|
|
* @see http://en.wikipedia.org/wiki/ISO_3166-2
|
|
* @see http://www.geonames.org/countries/
|
|
*/
|
|
final class SubdivisionCode extends AbstractSearcher
|
|
{
|
|
private string $countryName;
|
|
|
|
/**
|
|
* @var string[]
|
|
*/
|
|
private array $countryInfo;
|
|
|
|
public function __construct(string $countryCode)
|
|
{
|
|
$countryInfo = new CountryInfo($countryCode);
|
|
|
|
$this->countryName = $countryInfo->getCountry();
|
|
$this->countryInfo = array_keys($countryInfo->getSubdivisions());
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
protected function getDataSource(mixed $input = null): array
|
|
{
|
|
return $this->countryInfo;
|
|
}
|
|
}
|