You are here

private function Random::getRandomCountryInfo in Geocoder 7.2

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

Class

Random
Class Random.

Namespace

Drupal\geocoder\Plugin\Geocoder\Provider

Code

private function getRandomCountryInfo($type = NULL) {
  include_once DRUPAL_ROOT . '/includes/locale.inc';
  $countries = country_get_list();
  uksort($countries, function () {
    return rand() > rand();
  });
  $country = array_slice($countries, 0, 1);
  $value = array(
    'code' => key($country),
    'name' => reset($country),
  );
  if (is_null($type)) {
    return $value;
  }
  return isset($value[$type]) ? $value[$type] : $value;
}