composer require anisimov/emoji
$delimiter = new \Anisimov\Emoji\Delimiter\SingleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);
$stringWithEmoji = 'some string 😉';
$result = $emoji->encode($stringWithEmoji); // some string :wink:
$stringWithEncodedEmoji = 'some string :wink:';
$result = $emoji->decode($stringWithEmoji); // some string 😉
$delimiter = new \Anisimov\Emoji\Delimiter\DoubleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);
$stringWithEmoji = 'some string 😉';
$result = $emoji->encode($stringWithEmoji); // some string ::wink::
$stringWithEncodedEmoji = 'some string ::wink::';
$result = $emoji->decode($stringWithEmoji); // some string 😉
$delimiter = new \Anisimov\Emoji\Delimiter\TripleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);
$stringWithEmoji = 'some string 😉';
$result = $emoji->encode($stringWithEmoji); // some string :::wink:::
$stringWithEncodedEmoji = 'some string :::wink:::';
$result = $emoji->decode($stringWithEmoji); // some string 😉
$delimiter = new \Anisimov\Emoji\Delimiter\SingleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);
$stringWithEmoji = 'some string 😉';
$result = $emoji->hasEmoji($stringWithEmoji); // true
$stringWithoutEmoji = 'some string';
$result = $emoji->hasEmoji($stringWithoutEmoji); // false
$delimiter = new \Anisimov\Emoji\Delimiter\SingleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);
$stringWithEmoji = '😉 some 😉 😉 😉 string 😉';
$result = $emoji->remove($stringWithEmoji); // 'some string'
$delimiter = new \Anisimov\Emoji\Delimiter\SingleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);
$stringWithEmoji = '😀 some 😃 😄 string 😁 😆';
$result = $emoji->find($stringWithEmoji); // ['😀', '😃', '😄', '😁', '😆']
Create delimiter class that implements \Anisimov\Emoji\Delimiter\DelimiterInterface
.
\Anisimov\Emoji\Delimiter\DelimiterInterface::getRegexp
method should return regex to find delimiter wrapped emoji.
\Anisimov\Emoji\Delimiter\DelimiterInterface::getDelimiter
method should return delimiter symbols
For example, \Anisimov\Emoji\Delimiter\SingleColonDelimiter
\Anisimov\Emoji\Delimiter\SingleColonDelimiter::getRegexp
returns /[\:]{1}[^(\:|\s)]{1,}[\:]{1}/
\Anisimov\Emoji\Delimiter\SingleColonDelimiter::getDelimiter
returns :