/**
  * List of all countries.
  *
  * @link https://github.com/umpirsky/country-list/blob/master/country/cldr/en/country.php
  * @param string $locale
  * @access public
  * @return array
  * @static
  *
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public static function allCountries($locale, $strtolowerKeys = true)
 {
     //         // we get the current directory.
     //         $path = realpath(dirname(__FILE__) . "/Countries/cldr");
     //         $all_files = \Sfynx\ToolBundle\Util\PiFileManager::ListFiles($path, "json");
     //         foreach($all_files as $key => $path_file){
     //             $dir_path_win     = explode('\\', realpath(dirname($path_file)));
     //             $dir_path_linux = explode('//', realpath(dirname($path_file)));
     //             $local_value_win     = end($dir_path_win);
     //             $local_value_linux = end($dir_path_linux);
     //             if ($local_value_win != realpath(dirname($path_file))){
     //                 $new_path = realpath(dirname(__FILE__)) . "/Countries/" . $local_value_win . "_country.json";
     //                 copy($path_file, $new_path);
     //                 print_r($local_value_win);
     //                 print_r("<br />");
     //             }
     //         }
     //         exit;
     // we get the current directory.
     $path = realpath(dirname(__FILE__) . "/Countries");
     // we create the file name.
     //$locale = strtolower($locale);
     $file = "{$locale}_country.json";
     // we take all json files existing.
     $all_files = \Sfynx\ToolBundle\Util\PiFileManager::getFilesByType($path, "json");
     //print_r(file_get_contents($path.'/'.$file));exit;
     //print_r(get_object_vars(json_decode(file_get_contents(realpath($path.'/'.$file)))));exit;
     // we return the country.jon content file if it's existed.
     if (in_array($file, $all_files)) {
         $all_countries = get_object_vars(json_decode(file_get_contents(realpath($path . '/' . $file))));
     } else {
         $all_countries = get_object_vars(json_decode(file_get_contents(realpath($path . '/en_country.json'))));
     }
     asort($all_countries);
     if ($strtolowerKeys) {
         $news_key = array_map(function ($key) {
             return (string) strtolower($key);
         }, array_keys($all_countries));
         return array_combine($news_key, array_values($all_countries));
     } else {
         return $all_countries;
     }
 }