定制 flextype-components/number 二次开发

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

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

flextype-components/number

Composer 安装命令:

composer require flextype-components/number

包简介

The Number Component contains methods that can be useful when working with numbers.

关键字:

README 文档

README

version MIT License

The Number Component contains methods that can be useful when working with numbers.

Installation

composer require flextype-components/number

Usage

use Flextype\Component\Number\Number;

Converts a number of bytes to a human readable number by taking the number of that unit that the bytes will go into it.

echo Num::format_bytes('204800');     // 200 kB
echo Num::format_bytes('214901', 1);  // 209.9 kB
echo Num::format_bytes('2249010', 1); // 2.1 MB
echo Num::format_bytes('badbyteshere'); // false

Converts a file size number to a byte value.

echo Number::convertToBytes('200K');  // 204800
echo Number::convertToBytes('5MiB');  // 5242880
echo Number::convertToBytes('2.5GB'); // 2684354560

Converts a number into a more readable human-type number.

echo Number::quantity(7000); // 7K
echo Number::quantity(7500); // 8K
echo Number::quantity(7500, 1); // 7.5K

Checks if the value is between the minimum and maximum (min & max included).

if (Number::between(2, 10, 5)) {
    // do something...
}

Checks the value for an even number.

if (Number::even(2)) {
    // do something...
}

Checks if the value is greather than a given minimum.

if (Number::greaterThan(2, 10)) {
     // do something...
}

Checks if the value is smaller than a given maximum.

if (Number::smallerThan(2, 10)) {
     // do something...
}

Checks if the value is not greater than or equal a given maximum.

if (Number::maximum(2, 10)) {
     // do something...
}

Checks if the value is greater than or equal to a given minimum.

if (Number::minimum(2, 10)) {
     // do something...
}

Checks the value for an odd number.

if (Number::odd(2)) {
     // do something...
}

Transforms a number by masking characters in a specified mask format, and ignoring characters that should be injected into the string without matching a character from the original string (defaults to space).

// ************5678
echo Number::maskString('1234567812345678', '************0000');

// **** **** **** 5678
echo Number::maskString('1234567812345678', '**** **** **** 0000');

// **** - **** - **** - 5678
echo Number::maskString('1234567812345678', '**** - **** - **** - 0000', ' -');

Formats a number by injecting non-numeric characters in a specified format into the string in the positions they appear in the format.

// (123) 456-7890
echo Number::format('1234567890', '(000) 000-0000');

// 123.456.7890
echo Number::format('1234567890', '000.000.0000');

Formats a phone number.

// (061) 234 5678
echo Number::formatPhone('0612345678');

// (06) 123 456 78
echo Number::formatPhone('0612345678', '(00) 000 000 00');

Formats (masks) a credit card.

// **** **** **** 2938
echo Number::maskСreditСard('1234263583742938');

// 1234 **** **** ****
echo Number::maskСreditСard('1234123412341234', '0000 **** **** ****');

Formats a credit card expiration string. Expects 4-digit string (MMYY).

// 12-34
echo Number::formatExp('1234');

// 12/34
echo Number::formatExp('1234', '00/00');

License

See LICENSE

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固