You are here

private function Random::getRandomCountryInfo in Geocoder 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/Geocoder/Provider/Random.php \Drupal\geocoder\Plugin\Geocoder\Provider\Random::getRandomCountryInfo()
  2. 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 66

Class

Random
Class Random.

Namespace

Drupal\geocoder\Plugin\Geocoder\Provider

Code

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;
}