private function Random::getRandomCountryInfo in Geocoder 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/Geocoder/Provider/Random.php \Drupal\geocoder\Plugin\Geocoder\Provider\Random::getRandomCountryInfo()
- 7.2 src/Plugin/Geocoder/Provider/Random.php \Drupal\geocoder\Plugin\Geocoder\Provider\Random::getRandomCountryInfo()
Get Random Country info.
@todo [cc]: Tidy-up, document, etc.
1 call to Random::getRandomCountryInfo()
- Random::getRandomResult in src/
Plugin/ Geocoder/ Provider/ Random.php - Generate a fake random address array.
File
- src/
Plugin/ Geocoder/ Provider/ Random.php, line 56
Class
- Random
- Class Random.
Namespace
Drupal\geocoder\Plugin\Geocoder\ProviderCode
private function getRandomCountryInfo($type = NULL) {
$manager = new CountryManager($this
->getModuleHandler());
$countries = $manager
->getList();
uksort($countries, function () {
return rand() > rand();
});
$country = array_slice($countries, 0, 1);
$value = [
'code' => key($country),
'name' => reset($country),
];
if (is_null($type)) {
return $value;
}
return isset($value[$type]) ? $value[$type] : $value;
}