Skip to content
/ emoji Public

make parse and convert all of emoji symbols more simple than ever

License

Notifications You must be signed in to change notification settings

hidehalo/emoji

Folders and files

NameName
Last commit message
Last commit date
Mar 16, 2018
Mar 16, 2018
Mar 15, 2018
Apr 13, 2017
Feb 21, 2018
Feb 21, 2018
Feb 22, 2018
Jan 1, 2021
Mar 11, 2018
Mar 11, 2018
Feb 21, 2018

Repository files navigation

Emoji

Build Status FOSSA Status

If you want help with parse and store emoji symbol characters,you could think about use this library :)

Features

  1. Detected emoji symbols only
  2. Replace emoji symbols to other texts and turn it back
  3. Zero dependence
  4. Lightweight and fast

Install

$composer require hidehalo/emoji

Usage

Parser

require vendor/autoload.php;
use Hidehalo\Emoji\Parser;

$parser = new Parser();
$parser->parse($contents);

Converter

# if you want to replace those emoji symbols to ohter marked texts 
# and has ability to turn those back,
# it has a built-in Protocol and Converter could do this
# and $decoded will equals $raw,it is real very simple

use Hidehalo\Emoji\Converter;

$converter = new Converter($parser);
$encoded = $converter->encode($raw);
$decoded = $converter->decode($encoded);

# filter emojis
use Hidehalo\Emoji\Protocol\Filter;

$clean = $converter->encode($raw, new Filter);

Custom protocol

Maybe you want to impl your custom convert protocol,you can make it through implements ProtocolInterface

use Hidehalo\Emoji\Protocol\ProtocolInterface as Protocol;
use Hidehalo\Emoji\Protocol\PatternAwareTrait;

class CustomProto implments Protocol
{
    use PatternAwareTrait;

    protected $format = "FORMAT";
    protected $pattern = "/FORMAT/";

    public function encode($contents)
    {
        //your impls
    }

    public function decode($contents)
    {
        //your impls
    }
}
$customProto = new CustomProto;
$customEncoded = $converter->encode($raw, $customProto);
$customDecoded = $converter->decode($customDecoded, $customProto);

Testing

$./vendor/bin/phpunit

License

The MIT License (MIT). Please see License File for more information.

FOSSA Status