定制 poletaew/sms-segment-calculator 二次开发

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

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

poletaew/sms-segment-calculator

Composer 安装命令:

composer require poletaew/sms-segment-calculator

包简介

PHP-based tool to calculate and display SMS segmentation data for a given message body

README 文档

README

A PHP library that enables you to calculate the message segments used for sending a message on the GSM network. A port of Twillio's Segment Calculator.

Usage

Installation

composer require poletaew/sms-segment-calculator

Sample usage

use Poletaew\SmsSegmentCalculator\Models\SegmentedMessage;

$segmentedMessage = new SegmentedMessage('Hello World');

echo $segmentedMessage->getRealEncodingName() . PHP_EOL; // "GSM-7"
echo $segmentedMessage->getSegmentsCount(); // "1"

Documentation

SegmentedMessage class

This is the main class exposed by the package

__construct($message, $encoding, $smartEncoding)

Arguments:

  • $message: Body of the SMS
  • $encoding: Optional: encoding. It can be SmsEncoding enum value or auto. Default value: auto
  • $smartEncoding: Optional: if smart encoding enabled. Default value: false

getRealEncodingName()

Returns the name of the calculated encoding for the message: GSM-7 or UCS-2

getTotalSize()

Total size of the message in bits (including User Data Header if present)

getMessageSize()

Total size of the message in bits (excluding User Data Header if present)

getSegmentsCount()

Number of segment(s)

getNonGsmCharacters()

Return an array with the non GSM-7 characters in the body. It can be used to replace character and reduce the number of segments

getNumberOfUnicodeScalars()

Number of Unicode scalars

getNumberOfCharacters()

Number of characters

Contributing

This code is open source and welcomes contributions.

The source code for the library is all contained in the src folder. Before submitting a PR run Unit test in the directory test/Unit and make sure all tests pass.

License

MIT

Disclaimer

No warranty expressed or implied. Software is as is.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固