/ecoji-php

PHP port of Ecoji with 100% test coverage.

Primary LanguagePHPMIT LicenseMIT

Ecoji for PHP 🏣🔉🦐🔼🍉🔹🦒📲🐒🍍🀄☕

Ecoji encodes data as 1024 emojis. It's like base1024 with an emoji character set.

rayne/ecoji is a PHP port of Ecoji with 100% test coverage.

Latest Stable Version Code Coverage Scrutinizer Code Quality License

Contents

Installation

composer require rayne/ecoji

Encoding

use Rayne\Ecoji\Ecoji;

$ecoji = new Ecoji;
$ecoji->encode("Base64 is so 1999, isn\'t there something better?\n");
🏗📩🎦🐇🎛📘🔯🚜💞😽🆖🐊🎱🥁🚄🌱💞😭💮🇵💢🕥🐭🔸🍉🚲🦑🐶💢🕥🔮🔺🍉📸🐮🌼👦🚟🥴📑

Decoding

use Rayne\Ecoji\Ecoji;

$ecoji = new Ecoji;
$ecoji->decode('🏗📩🎦🐇🎛📘🔯🚜💞😽🆖🐊🎱🥁🚄🌱💞😭💮🇵💢🕥🐭🔸🍉🚲🦑🐶💢🕥🔮🔺🍉📸🐮🌼👦🚟🥴📑');
Base64 is so 1999, isn't there something better?

Streams

use Rayne\Ecoji\Ecoji;

$ecoji = new EcojiStream;
$ecoji->encode($sourceStream, $destinationStream);
$ecoji->decode($sourceStream, $destinationStream);

EcojiStream doesn't wrap the encoded stream without configuring the wrap length first. A value of 0 disables wrapping.

use Rayne\Ecoji\Ecoji;

$ecoji = new EcojiStream;
$ecoji->setWrap(80);

CLI

The CLI encodes and decodes files and streams.

./bin/ecoji --help
Usage: ecoji [OPTIONS]... [FILE]

Encode or decode data as Unicode emojis. 😁

Options:
    -d, --decode          Decode data.
    -w, --wrap COLS       Wrap encoded lines after COLS characters (default 76).
                          Use 0 to disable line wrapping.
    -h, --help            Print this message.
    -v, --version         Print version information.

Installing the Composer package rayne/ecoji will create a symlink, e.g. vendor/bin/ecoji.

Docker

Launch a temporary Ecoji Docker container to utilize the CLI:

docker run -it --rm rayne/ecoji --help

Pipe data through a container:

echo -n "Ecoji for Docker" | docker run -i --rm rayne/ecoji
🏣🔉🦐🔼🍉🔹🦒📲🏟🙁🎧🤒💙☕☕☕

Encode or decode a file by mounting it as volume or piping its content through a container:

docker run -it --rm -v /my/message:/file rayne/ecoji /file
cat /my/message | docker run -i --rm rayne/ecoji

Build Image

docker build -t rayne/ecoji:"$(cat assets/version.txt)" -t rayne/ecoji:latest .