项目作者: hidehalo

项目描述 :
make parse and convert all of emoji symbols more simple than ever
高级语言: PHP
项目地址: git://github.com/hidehalo/emoji.git
创建时间: 2016-08-25T16:35:10Z
项目社区:https://github.com/hidehalo/emoji

开源协议:MIT License

下载


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

  1. $composer require hidehalo/emoji

Usage

Parser

  1. require vendor/autoload.php;
  2. use Hidehalo\Emoji\Parser;
  3. $parser = new Parser();
  4. $parser->parse($contents);

Converter

  1. # if you want to replace those emoji symbols to ohter marked texts
  2. # and has ability to turn those back,
  3. # it has a built-in Protocol and Converter could do this
  4. # and $decoded will equals $raw,it is real very simple
  5. use Hidehalo\Emoji\Converter;
  6. $converter = new Converter($parser);
  7. $encoded = $converter->encode($raw);
  8. $decoded = $converter->decode($encoded);
  9. # filter emojis
  10. use Hidehalo\Emoji\Protocol\Filter;
  11. $clean = $converter->encode($raw, new Filter);

Custom protocol

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

  1. use Hidehalo\Emoji\Protocol\ProtocolInterface as Protocol;
  2. use Hidehalo\Emoji\Protocol\PatternAwareTrait;
  3. class CustomProto implments Protocol
  4. {
  5. use PatternAwareTrait;
  6. protected $format = "FORMAT";
  7. protected $pattern = "/FORMAT/";
  8. public function encode($contents)
  9. {
  10. //your impls
  11. }
  12. public function decode($contents)
  13. {
  14. //your impls
  15. }
  16. }
  17. $customProto = new CustomProto;
  18. $customEncoded = $converter->encode($raw, $customProto);
  19. $customDecoded = $converter->decode($customDecoded, $customProto);

Testing

  1. $./vendor/bin/phpunit

License

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

FOSSA Status