Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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 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](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)