PHP Class Telegram\Bot\Helpers\Emojify

Show file Open project: irazasyed/telegram-bot-sdk

Protected Properties

Property Type Description
$emojiMap array The array mapping words to emoji.
$emojiMapFile string The path to the file containing the emoji map.
$wordMap array The array mapping emoji back to words.

Public Methods

Method Description
getInstance ( ) : Emojify Returns the *Singleton* instance of this class.
setEmojiMapFile ( string $emojiMapFile ) : Emojify Set File Path to Emoji Map File.
text ( $text ) : mixed Alias of toEmoji()
toEmoji ( $text ) : mixed Translate Word to Emoji
toWord ( $text ) : mixed Translate Emoji to Word
translate ( $text ) : mixed Alias of toWord()

Protected Methods

Method Description
__construct ( ) Protected Emojify constructor to prevent creating a new instance of the *Singleton* via the new operator from outside of this class.
emojiToWordReplace ( $line, $replace, $delimiter ) : mixed Finds emojis and replaces them with text enclosed by the delimiter
getEmojiMap ( ) : array Get Emoji Map Array.
replace ( $line, $replace, boolean $toWord = false, string $delimiter = ':' ) : mixed Replace
setupEmojiMaps ( ) Setup Emoji Maps.
wordToEmojiReplace ( $line, $replace, $delimiter ) : mixed Finds words enclosed by the delimiter and converts them to the appropriate emoji character.

Private Methods

Method Description
__clone ( ) : void Private clone method to prevent cloning of the instance of the *Singleton* instance.
__wakeup ( ) : void Private unserialize method to prevent unserializing of the *Singleton* instance.

Method Details

__construct() protected method

Protected Emojify constructor to prevent creating a new instance of the *Singleton* via the new operator from outside of this class.
protected __construct ( )

emojiToWordReplace() protected method

Finds emojis and replaces them with text enclosed by the delimiter
protected emojiToWordReplace ( $line, $replace, $delimiter ) : mixed
$line
$replace
$delimiter
return mixed

getEmojiMap() protected method

Get Emoji Map Array.
protected getEmojiMap ( ) : array
return array

getInstance() public static method

Returns the *Singleton* instance of this class.
public static getInstance ( ) : Emojify
return Emojify The *Singleton* instance.

replace() protected method

Replace
protected replace ( $line, $replace, boolean $toWord = false, string $delimiter = ':' ) : mixed
$line
$replace
$toWord boolean
$delimiter string
return mixed

setEmojiMapFile() public method

Set File Path to Emoji Map File.
public setEmojiMapFile ( string $emojiMapFile ) : Emojify
$emojiMapFile string
return Emojify

setupEmojiMaps() protected method

Setup Emoji Maps.
protected setupEmojiMaps ( )

text() public static method

Alias of toEmoji()
public static text ( $text ) : mixed
$text
return mixed

toEmoji() public method

Translate Word to Emoji
public toEmoji ( $text ) : mixed
$text
return mixed

toWord() public method

Translate Emoji to Word
public toWord ( $text ) : mixed
$text
return mixed

translate() public static method

Alias of toWord()
public static translate ( $text ) : mixed
$text
return mixed

wordToEmojiReplace() protected method

Finds words enclosed by the delimiter and converts them to the appropriate emoji character.
protected wordToEmojiReplace ( $line, $replace, $delimiter ) : mixed
$line
$replace
$delimiter
return mixed

Property Details

$emojiMap protected property

The array mapping words to emoji.
protected array $emojiMap
return array

$emojiMapFile protected property

The path to the file containing the emoji map.
protected string $emojiMapFile
return string

$wordMap protected property

The array mapping emoji back to words.
protected array $wordMap
return array