SOP.wtf/user
2022-09-24 06:29:00 +00:00
..
_base.scss Upload files to 'user' 2022-09-24 06:29:00 +00:00
admin-page.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
animate.min.css Upload files to 'user' 2022-09-24 06:29:00 +00:00
autoload_classmap.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
autoload_namespaces.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
autoload_psr4.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
autoload_real.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
autoload_static.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
autoload.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
blockpage.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
bootstrap.min.css Upload files to 'user' 2022-09-24 06:29:00 +00:00
class-gsb.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
ClassLoader.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
composer.json Upload files to 'user' 2022-09-24 06:29:00 +00:00
composer.lock Upload files to 'user' 2022-09-24 06:29:00 +00:00
config.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
CONTRIBUTING.md Upload files to 'user' 2022-09-24 06:29:00 +00:00
dark.css Upload files to 'user' 2022-09-24 06:29:00 +00:00
dark.scss Upload files to 'user' 2022-09-24 06:29:00 +00:00
delete.png Upload files to 'user' 2022-09-24 06:29:00 +00:00
edit.png Upload files to 'user' 2022-09-24 06:29:00 +00:00
EmojiDetector.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
EmojiDetectorTest.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
EmojiInfo.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
emojis.txt Upload files to 'user' 2022-09-24 06:29:00 +00:00
favicon.ico Upload files to 'user' 2022-09-24 06:29:00 +00:00
form.html Upload files to 'user' 2022-09-24 06:29:00 +00:00
FUNDING.yml Upload files to 'user' 2022-09-24 06:29:00 +00:00
get_emojis.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
gpl-3.0.txt Upload files to 'user' 2022-09-24 06:29:00 +00:00
http_BL.sql Upload files to 'user' 2022-09-24 06:29:00 +00:00
installed.json Upload files to 'user' 2022-09-24 06:29:00 +00:00
LICENSE Upload files to 'user' 2022-09-24 06:29:00 +00:00
LICENSE.md Upload files to 'user' 2022-09-24 06:29:00 +00:00
light.css Upload files to 'user' 2022-09-24 06:29:00 +00:00
light.scss Upload files to 'user' 2022-09-24 06:29:00 +00:00
logo_black.png Upload files to 'user' 2022-09-24 06:29:00 +00:00
logo_black.webp Upload files to 'user' 2022-09-24 06:29:00 +00:00
logo_white.png Upload files to 'user' 2022-09-24 06:29:00 +00:00
logo_white.webp Upload files to 'user' 2022-09-24 06:29:00 +00:00
ludo_blacklist_ip_Check_IP_Module.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
map.json Upload files to 'user' 2022-09-24 06:29:00 +00:00
MapGenerator.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
no-entry.png Upload files to 'user' 2022-09-24 06:29:00 +00:00
package-lock.json Upload files to 'user' 2022-09-24 06:29:00 +00:00
package.json Upload files to 'user' 2022-09-24 06:29:00 +00:00
php.yml Upload files to 'user' 2022-09-24 06:29:00 +00:00
phpunit.xml.dist Upload files to 'user' 2022-09-24 06:29:00 +00:00
plugin.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
raw.json Upload files to 'user' 2022-09-24 06:29:00 +00:00
readme.md Upload files to 'user' 2022-09-24 06:29:00 +00:00
README.md Upload files to 'user' 2022-09-24 06:29:00 +00:00
README.textile Upload files to 'user' 2022-09-24 06:29:00 +00:00
share.png Upload files to 'user' 2022-09-24 06:29:00 +00:00
stats.png Upload files to 'user' 2022-09-24 06:29:00 +00:00
tests.php Upload files to 'user' 2022-09-24 06:29:00 +00:00
theme.js Upload files to 'user' 2022-09-24 06:29:00 +00:00

PHP Emoji Detector

Latest Stable Version Total Downloads License Build Status

Have an input string full of emoji's and you want to know detailed information about each emoji? Want to build an easy way to validate emoji's that come in as input data?

This 👏 is 👏 the 👏 library 👏 you 👏 want!

What does this thing do?

This library simply parses input strings and returns a list of relevant information about emoji's that are present in the string. It currently supports version 12.1 of the emoji standard.

Installation

Install this library using composer

$ composer require steppinghat/emoji-detector

Usage

The Model

For most outputs, the library will provide an EmojiInfo object that contains all of the relevant information about an emoji. The object will contain the following information:

Property Description
emoji The emoji chacater itself
name A user friendly name of the specific emoji
shortName A shortened name of the emoji
category A user friendly category name for the emoji
skinTone The level of skin tone of the emoji (if present)
hexCodes An array of individual hexadecimal characters that are used to make up the emoji
offset The position in the string where the emoji starts
mbOffset The multibyte position in the string where the emoji starts

All of these properties are protected, but can be accessed by their appropriate getters and setters. E.g. getCategory() or setSkinTone().

Emoji detection

<?php

require_once('vendor/autoload.php');

use SteppingHat\EmojiDetector;

$input = "Hello 👋 world!";
$detector = EmojiDetector();
$emojis = $detector->detect($input);

print_r($emojis);

This example is the most common usage of the detector, returning an array of objects that provide detailed information about each emoji found in the input string.

Array
(
    [0] => SteppingHat\EmojiDetector\Model\EmojiInfo Object
        (
            [emoji:protected] => 👋
            [name:protected] => waving hand
            [shortName:protected] => hand-fingers-open
            [category:protected] => People & Body
            [skinTone:protected] =>
            [hexCodes:protected] => Array
                (
                    [0] => 1F44B
                )

            [offset:protected] => 6
            [mbOffset:protected] => 6
        )

)

The library has full support for complex emoji's that make use of the ZWJ (Zero Width Joiner) character.

<?php

require_once('vendor/autoload.php');

use SteppingHat\EmojiDetector;

$input = "I ❤️ to 👨‍💻";
$detector = new SteppingHat\EmojiDetector\EmojiDetector();
$emojis = $detector->detect($input);

print_r($emojis);

The above will produce the following output:

Array
(
    [0] => SteppingHat\EmojiDetector\Model\EmojiInfo Object
        (
            [emoji:protected] => ❤️
            [name:protected] => red heart
            [shortName:protected] => emotion
            [category:protected] => Smileys & Emotion
            [skinTone:protected] => 
            [hexCodes:protected] => Array
                (
                    [0] => 2764
                    [1] => FE0F
                )

            [offset:protected] => 2
            [mbOffset:protected] => 2
        )

    [1] => SteppingHat\EmojiDetector\Model\EmojiInfo Object
        (
            [emoji:protected] => 👨‍💻
            [name:protected] => man technologist
            [shortName:protected] => person-role
            [category:protected] => People & Body
            [skinTone:protected] => 
            [hexCodes:protected] => Array
                (
                    [0] => 1F468
                    [1] => 200D
                    [2] => 1F4BB
                )

            [offset:protected] => 13
            [mbOffset:protected] => 9
        )

)

Testing for single emojis

Sometimes it is handy to test if an input string is a single emoji on it's own.

<?php

require_once('vendor/autoload.php');

use SteppingHat\EmojiDetector;

$detector = new SteppingHat\EmojiDetector\EmojiDetector();

$detector->isSingleEmoji("💩"); // Returns TRUE
$detector->isSingleEmoji("Time to dance 🌚"); // Returns FALSE
$detector->isSingleEmoji("🍆🍒"); // Returns FALSE

Tests

Included for library development purposes is a small set of test cases to assure that basic library functions work as expected. These tests can be launched by running the following:

$ php vendor/bin/simple-phpunit

License

Made with ❤️ by Javan Eskander

Available for use under the MIT license.

Emoji data sourced from amio/emoji.json