getCountries() public méthode

public getCountries ( ) : MemberCollection
Résultat MenaraSolutions\Geographer\Collections\MemberCollection
 /**
  * @test
  */
 public function most_states_of_all_countries_have_cities()
 {
     $planet = new Earth();
     $countries = $planet->getCountries();
     foreach ($countries as $country) {
         $citiesCount = 0;
         foreach ($country->getStates() as $state) {
             $cities = $state->getCities();
             foreach ($cities as $city) {
                 $citiesCount++;
                 $array = $city->toArray();
                 $this->assertTrue(isset($array['code']) && is_int($array['code']));
                 $this->assertTrue(isset($array['name']) && is_string($array['name']));
                 if ($country->getCode() == 'RU') {
                     //$city->setLanguage('ru')->inflict('from');
                     //echo $city->getName() . "\n";
                 }
             }
         }
         if (!in_array($country->getCode(), $this->emptyCountries)) {
             //if ($citiesCount == 0) echo $country->getCode();
             //if ($citiesCount == 0) echo count($country->getStates());
             $this->assertTrue($citiesCount > 0);
         }
     }
 }
 /**
  * @test
  */
 public function all_countries_have_translated_names()
 {
     $earth = new Earth();
     $countries = $earth->getCountries();
     foreach ($countries as $country) {
         $this->assertNotEquals($country->setLocale($this->languageCode)->getName(), $country->setLocale('en')->getName());
         //echo $country->inflict('from')->setLocale($this->languageCode)->getName() . "\n";
     }
 }
 /**
  * @test
  */
 public function can_filter_the_countries()
 {
     $earth = new Earth();
     $countries = $earth->getCountries();
     $count = $countries->count();
     $countries = $countries->filter(function ($item) {
         return $item->getPopulation() > 50000;
     });
     $this->assertNotEquals($count, $countries->count());
 }
 /**
  *
  */
 public function all_states_have_iso_codes()
 {
     $codes = file_get_contents(dirname(dirname(dirname(__FILE__))) . '/iso3166-2.csv');
     $line = strtok($codes, "\r\n");
     $countryData = [];
     while ($line !== false) {
         $line = str_replace('"', '', $line);
         list($country, $name, $code) = explode(',', $line);
         if (!isset($countryData[$country])) {
             $countryData[$country] = [];
         }
         if ($code != '-') {
             $countryData[$country][] = ['name' => $name, 'code' => $code];
         }
         $line = strtok("\r\n");
     }
     $planet = new Earth();
     $countries = $planet->getCountries();
     $guesses = 0;
     foreach ($countries as $country) {
         $filename = dirname(dirname(dirname(dirname(__FILE__)))) . '/resources/states/' . $country->getCode() . '.json';
         if (!file_exists($filename)) {
             continue;
         }
         $states = file_get_contents($filename);
         $states = json_decode($states, true);
         $counter = 0;
         $meta = isset($countryData[$country->getCode()]) ? $countryData[$country->getCode()] : [];
         foreach ($states as &$state) {
             if (!isset($state['ids']['iso_3166_2'])) {
                 $counter++;
             }
             $name = $state['long']['default'];
             if (isset($state['ids']['iso_3166'])) {
                 unset($state['ids']['iso_3166']);
             }
             if ($country->getFipsCode() && isset($state['ids']['fips']) && is_numeric($state['ids']['fips'])) {
                 $state['ids']['fips'] = $country->getFipsCode() . $state['ids']['fips'];
             }
             foreach ($meta as $oneMeta) {
                 similar_text($oneMeta['name'], $name, $percent);
                 if ($percent > 90) {
                     if (substr($oneMeta['code'], 0, 2) != $country->getCode()) {
                         continue;
                     }
                     //echo "Found a match for " . $name . " = " . $oneMeta['code'] . "\n";
                     $state['ids']['iso_3166_2'] = $oneMeta['code'];
                     $guesses++;
                 }
             }
         }
         $total = count($meta);
         echo "Country " . $country->getCode() . " has " . $counter . "/" . $total . " states\n";
         if ($total == 0 || $counter >= $total) {
             continue;
         }
     }
     echo "Guesses: " . $guesses . "\n";
 }