Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hidehalo/emoji
make parse and convert all of emoji symbols more simple than ever
https://github.com/hidehalo/emoji
composer-package emoji emoji-filter emoji-parser emoji-symbols fast lightweight php zero-dependency
Last synced: 2 months ago
JSON representation
make parse and convert all of emoji symbols more simple than ever
- Host: GitHub
- URL: https://github.com/hidehalo/emoji
- Owner: hidehalo
- License: mit
- Created: 2016-08-25T16:35:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-05-27T03:41:18.000Z (over 3 years ago)
- Last Synced: 2024-08-09T03:26:26.323Z (5 months ago)
- Topics: composer-package, emoji, emoji-filter, emoji-parser, emoji-symbols, fast, lightweight, php, zero-dependency
- Language: PHP
- Homepage:
- Size: 160 KB
- Stars: 31
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Emoji
[![Build Status](https://travis-ci.org/hidehalo/emoji.svg)](https://travis-ci.org/hidehalo/emoji)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhidehalo%2Femoji.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhidehalo%2Femoji?ref=badge_shield)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
```bash
$composer require hidehalo/emoji
```## Usage
### Parser
```php
require vendor/autoload.php;
use Hidehalo\Emoji\Parser;$parser = new Parser();
$parser->parse($contents);
```### Converter
```php
# 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 simpleuse 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](src/Protocol/ProtocolInterface.php)
```php
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
```bash
$./vendor/bin/phpunit
```## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhidehalo%2Femoji.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhidehalo%2Femoji?ref=badge_large)