public static function flag(string $country, string $size = 'medium') : string
    {
        $sizes = [
            'small' => 100,
            'medium' => 250,
            'big' => 1000,
        ];

        $code = $country;

        if (strlen($country) > 2) {
            $code = static::countryAlpha2($country);
        }

        $code = strtolower($code);

        if ($code === 'unknown') {
            $flag = __DIR__ . "/../Assets/country-flags/Unknown.png";
        } else {
            $flag = __DIR__ . "/../Assets/country-flags/png{$sizes[$size]}px/{$code}.png";
        }

        $cache_key = "support__flag:{$code}_{$size}";

        if (!Cache::has($cache_key)) {
            $image = Image::make($flag)
                ->resize($sizes[$size], bcmul($sizes[$size], 0.6, 2))
                ->encode('data-url');
            Cache::put($cache_key, $image);
            return $image;
        }

        return Cache::get($cache_key);
    }
public static function flag(string $country, string $size = 'medium') : string
    {
        $sizes = [
            'small' => 100,
            'medium' => 250,
            'big' => 1000,
        ];

        $code = $country;

        if (strlen($country) > 2) {
            $code = static::countryAlpha2($country);
        }

        $code = strtolower($code);

        if ($code === 'unknown') {
            $flag = __DIR__ . "/../Assets/country-flags/Unknown.png";
        } else {
            $flag = __DIR__ . "/../Assets/country-flags/png{$sizes[$size]}px/{$code}.png";
        }

        $cache_key = "support__flag:{$code}_{$size}";

        if (!Cache::has($cache_key)) {
            $image = Image::make($flag)
                ->resize($sizes[$size], bcmul($sizes[$size], 0.6, 2))
                ->encode('data-url');
            Cache::put($cache_key, $image);
            return $image;
        }

        return Cache::get($cache_key);
    }
public static function flag ( string $ country , string $ size = 'medium' ) : string { $ sizes = [ 'small' => 100 , 'medium' => 250 , 'big' => 1000 , ] ; $ code = $ country ; if ( strlen ( $ country ) > 2 ) { $ code = static :: countryAlpha2 ( $ country ) ; } $ code = strtolower ( $ code ) ; if ( $ code === 'unknown' ) { $ flag = __DIR__ . "/../Assets/country-flags/Unknown.png" ; } else { $ flag = __DIR__ . "/../Assets/country-flags/png{$sizes[$size]}px/{$code}.png" ; } $ cache_key = "support__flag:{$code}_{$size}" ; if ( ! Cache :: has ( $ cache_key ) ) { $ image = Image :: make ( $ flag ) -> resize ( $ sizes [ $ size ] , bcmul ( $ sizes [ $ size ] , 0.6 , 2 ) ) -> encode ( 'data-url' ) ; Cache :: put ( $ cache_key , $ image ) ; return $ image ; } return Cache :: get ( $ cache_key ) ; }
Returns the country image.

@author Erik Campobadal Fores <soc@erik.cat>
@copyright 2017 erik.cat
@param string $country
@param string $size small|medium|big
@return string
Returns the country image .