Skip to content

Instantly share code, notes, and snippets.

@ismail1432
Last active January 30, 2022 00:02
Show Gist options
  • Save ismail1432/effc827ffd453de200818bd49d4af8d5 to your computer and use it in GitHub Desktop.
Save ismail1432/effc827ffd453de200818bd49d4af8d5 to your computer and use it in GitHub Desktop.
<?php
class EmojiType extends AbstractType
{
public function getParent()
{
return CountryType::class;
}
public static function getEmojiFlag(string $countryCode): string
{
$regionalOffset = 0x1F1A5;
return mb_chr($regionalOffset + mb_ord($countryCode[0], 'UTF-8'), 'UTF-8')
. mb_chr($regionalOffset + mb_ord($countryCode[1], 'UTF-8'), 'UTF-8');
}
public function configureOptions(OptionsResolver $resolver)
{
// the magic is coming, continue to read
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment