public static function countries(string $continent = null, bool $only_names = false) : Collection
    {
        if (!$continent) {
            return static::getWorldContries($only_names);
        }

        $file = __DIR__ . "/../Assets/topojson/continents/{$continent}.json";

        if (!file_exists($file)) {
            return Collection::make([]);
        }

        $countries = Collection::make(
            json_decode(file_get_contents($file), true)
            ['objects']['continent_' . ucfirst($country) . '_subunits']['geometries']
        )->map(function ($country) {
            return $country['properties'];
        });

        if ($only_names) {
            $countries = $countries->map(function ($country) {
                return $country['geounit'];
            });
        }

        return $countries;
    }
public static function countries(string $continent = null, bool $only_names = false) : Collection
    {
        if (!$continent) {
            return static::getWorldContries($only_names);
        }

        $file = __DIR__ . "/../Assets/topojson/continents/{$continent}.json";

        if (!file_exists($file)) {
            return Collection::make([]);
        }

        $countries = Collection::make(
            json_decode(file_get_contents($file), true)
            ['objects']['continent_' . ucfirst($country) . '_subunits']['geometries']
        )->map(function ($country) {
            return $country['properties'];
        });

        if ($only_names) {
            $countries = $countries->map(function ($country) {
                return $country['geounit'];
            });
        }

        return $countries;
    }
public static function countries ( string $ continent = null , bool $ only_names = false ) : Collection { if ( ! $ continent ) { return static :: getWorldContries ( $ only_names ) ; } $ file = __DIR__ . "/../Assets/topojson/continents/{$continent}.json" ; if ( ! file_exists ( $ file ) ) { return Collection :: make ( [ ] ) ; } $ countries = Collection :: make ( json_decode ( file_get_contents ( $ file ) , true ) [ 'objects' ] [ 'continent_' . ucfirst ( $ country ) . '_subunits' ] [ 'geometries' ] ) -> map ( function ( $ country ) { return $ country [ 'properties' ] ; } ) ; if ( $ only_names ) { $ countries = $ countries -> map ( function ( $ country ) { return $ country [ 'geounit' ] ; } ) ; } return $ countries ; }
Return the countries of the given continent.

@author Erik Campobadal Fores <soc@erik.cat>
@copyright 2017 erik.cat
@param string $continent
@param bool|boolean $only_names
@return Collection
Return the countries of the given continent .