<NME> EmojiTest.php
<BEF> <?php

namespace Spatie\Emoji\Test;

use Spatie\Emoji\Emoji;
use PHPUnit\Framework\TestCase;
use Spatie\Emoji\Exceptions\UnknownCharacter;

class EmojiTest extends TestCase
{
    /** @test */
    public function it_can_return_an_emoji_character_when_given_a_constant()
    {
        $this->assertSame('😀', Emoji::CHARACTER_GRINNING_FACE);
        $this->assertSame('🥰', Emoji::CHARACTER_SMILING_FACE_WITH_HEARTS);
        $this->assertSame('🔟', Emoji::CHARACTER_KEYCAP_10);
    }

    /** @test */
    public function it_provides_a_convenience_method_to_return_emoji_characters()
    {
        $this->assertSame('😀', Emoji::grinningFace());
        $this->assertSame('🥰', Emoji::smilingFaceWithHearts());
        $this->assertSame('🔟', Emoji::keycap10());
        $this->assertSame('🥇', Emoji::firstPlaceMedal());
        $this->assertSame('🥈', Emoji::secondPlaceMedal());
        $this->assertSame('🥉', Emoji::thirdPlaceMedal());
    }

    /** @test */
    public function it_can_return_the_skin_tone_component_emoji()
    {
        $this->assertSame('🏻', Emoji::lightSkinTone());
    }

    /** @test */
    /** @test */
    public function it_will_return_an_emoji_character_when_given_a_language_code()
    {
        $this->assertSame('🇧🇪', Emoji::getCountryFlag('BE'));
    }

    /** @test */
    public function it_will_return_an_emoji_character_when_given_a_language_code_in_lower_case()
    {
        $this->assertSame('🇧🇪', Emoji::getCountryFlag('be'));
    }

    /** @test */
    public function it_will_not_crash_when_a_country_code_does_not_exist()
    {
        $this->assertSame('🇦🇦', Emoji::getCountryFlag('AA'));
    }
}
        $this->assertSame($this->unicodeHexToEmoji($code), Emoji::all()[$const]);
    }

    /**
     * @test
     *
     * @dataProvider invalidCountryCodeProvider
     */
    public function it_will_throw_an_exception_when_try_to_get_a_flag_for_a_string_that_doesnt_have_two_characters(string $invalidCountryCode)
    {
        $this->expectException(CouldNotDetermineFlag::class);

        Emoji::countryFlag($invalidCountryCode);
    }

    /**
     * @test
     *
     * @dataProvider codeToCallableProvider
     */
    public function can_access_emoji_by_constant($name, $code, $cleanName, $const, $method)
    {
        $this->assertEquals($this->unicodeHexToEmoji($code), Emoji::{$method}());
    }

    /**
     * @test
     *
     * @dataProvider codeToCallableProvider
     */
    public function can_access_emoji_by_method($name, $code, $cleanName, $const, $method)
    {
        $this->assertEquals($this->unicodeHexToEmoji($code), constant(Emoji::class.'::'.$const));
    }

    public function invalidCountryCodeProvider()
    {
        return [
            [''],
            ['a'],
            ['aaa'],
        ];
    }

    public function codeToCallableProvider(): array
    {
        return json_decode(file_get_contents(__DIR__.'/emojis.json'), true);
    }

    private function unicodeHexToEmoji(string $code)
    {
        return mb_convert_encoding(hex2bin(implode('', array_map(function ($hex) {
            return str_pad($hex, 8, '0', STR_PAD_LEFT);
        }, explode(' ', trim(str_replace('}\u{', ' ', $code), '}\u{'))))), 'UTF-8', 'UTF-32');
    }
}

<MSG> polish PR

<DFF> @@ -4,6 +4,7 @@ namespace Spatie\Emoji\Test;
 
 use Spatie\Emoji\Emoji;
 use PHPUnit\Framework\TestCase;
+use Spatie\Emoji\Exceptions\CouldNotDetermineFlag;
 use Spatie\Emoji\Exceptions\UnknownCharacter;
 
 class EmojiTest extends TestCase
@@ -37,18 +38,29 @@ class EmojiTest extends TestCase
     /** @test */
     public function it_will_return_an_emoji_character_when_given_a_language_code()
     {
-        $this->assertSame('🇧🇪', Emoji::getCountryFlag('BE'));
+        $this->assertSame('🇧🇪', Emoji::countryFlag('BE'));
+        $this->assertSame('🇧🇪', Emoji::countryFlag('be'));
+        $this->assertSame('🇦🇦', Emoji::countryFlag('AA'));
     }
 
-    /** @test */
-    public function it_will_return_an_emoji_character_when_given_a_language_code_in_lower_case()
+    /**
+     * @test
+     *
+     * @dataProvider invalidCountryCodeProvider
+     */
+    public function it_will_throw_an_exception_when_try_to_get_a_flag_for_a_string_that_doesnt_have_two_characters(string $invalidCountryCode)
     {
-        $this->assertSame('🇧🇪', Emoji::getCountryFlag('be'));
+        $this->expectException(CouldNotDetermineFlag::class);
+
+        Emoji::countryFlag($invalidCountryCode);
     }
 
-    /** @test */
-    public function it_will_not_crash_when_a_country_code_does_not_exist()
+    public function invalidCountryCodeProvider()
     {
-        $this->assertSame('🇦🇦', Emoji::getCountryFlag('AA'));
+        return [
+            [''],
+            ['a'],
+            ['aaa'],
+        ];
     }
 }

{'addition_count': 19, 'commit_subject': 'polish PR', 'deletion_count': 7, 'file_extension': '.php', 'lang': 'php', 'license': 'mit', 'repo_name': 'spatie/emoji'}