定制 itsnubix/emoji 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

itsnubix/emoji

Composer 安装命令:

composer require itsnubix/emoji

包简介

A PHP Library for interacting with Emojis

README 文档

README

Adds support for inserting and converting emojis into unicode in PHP. Uses enums and so requires PHP8.1 or higher.

Installation

composer require itsnubix/emoji

Usage

Below you will find some usage examples.

use Emoji\Emoji;
use Emoji\SkinTone;

// Globally set skin tone for all applicable emojis
Emoji::setDefaultSkinTone(SkinTone::medium);

// Various methods for spitting out a unicode emoji
Emoji::get('grinning_face')->toString(); // returns 😀
(string) Emoji::grinning_face(); // returns 😀
echo Emoji::grinningFace(); // returns 😀

// Overwrite the default skin tone on the fly
Emoji::get('waving_hand', SkinTone::light)->toString(); // returns 👋🏻
Emoji::wavingHand()->light()->toString(); // returns 👋🏻
Emoji::wavingHand()->skinTone('light')->toString(); // returns 👋🏻

// Also supports dynamic skin tone selection with a callback
$user = new User(['preferred_skin_tone' => SkinTone::light])
Emoji::wavingHand()
  ->skinTone(fn() => $user->preferred_skin_tone)
  ->toString();

// You may also remove tone from a given emoji as well.
$emoji = Emoji::wavingHand(SkinTone::medium);
$emoji->skinTone(); // get the skin tone, returns SkinTone::medium
$emoji->toneless()->skinTone(); // returns null

// Finally, you may replace emojis in a string where they match within
// two colons and align to an allowed emoji character. If invalid characters
// are used it just returns them without converting
Emoji::parse('Hello world :waving_hand: how are you :invalid_character:'); // returns "Hello world 👋" how are you :invalid_character:"

// You can set the skin tone for the parser globally with...
Emoji::setDefaultSkinTone(Emoji::light);
Emoji::parse('Hello world :waving_hand:'); // returns "Hello world 👋🏻"

For a full list of supported emojis and those that support adding skin tones view: Character

For a full list of skin tones view: SkinTone

Todo

  • Allow a user to select emojis
  • Allow a user to set skin tones
  • Add support for all emoji skin tones
  • Add support for changing skin tone when replacing a string

统计信息

  • 总下载量: 239
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固