php-extended/php-integer-capacity-object
最新稳定版本:8.0.10
Composer 安装命令:
composer require php-extended/php-integer-capacity-object
包简介
A library that implements the php-extended/php-integer-capacity-interface package
README 文档
README
A library that implements the php-extended/php-integer-capacity-interface package
Installation
The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.
- Download
composer.pharfrom their website. - Then run the following command to install this library as dependency :
php composer.phar php-extended/php-integer-capacity-object ^8
Basic Usage
This library provides 4 classes to specify integer capacities from different containers.
- The
BitIntegerCapacityclass uses bits to count the capacity of integers - The
ByteIntegerCapacityclass uses 8-bits bytes to count the capacity of integers - The
StringIntegerCapacityclass uses decimal digits arranged in a string to count the capacity of integers - The
HexaIntegerCapacityclass uses hexadecimal digits arranged in a string to count the capacity of integers.
All those classes are usable the following way:
use PhpExtended\Model\BitIntegerCapacity;
use PhpExtended\Model\ByteIntegerCapacity;
use PhpExtended\Model\StringIntegerCapacity;
$capacity = new BitIntegerCapacity(32);
// $capacity is now a 32-bit integer capacity
$capacity = new ByteIntegerCapacity($capacity);
// $capacity is now a 4-byte integer capacity
$capacity = new StringIntegerCapacity($capacity);
// $capacity is now a 10-digits integer capacity
$capacity = new BitIntegerCapacity($capacity);
// $capacity is now a 33-bit integer capacity
// note that due to roundings and the ever expanding
// available maximum value, the number of bits needed to
// encode the same information increases !
All those classes may be built with a positive non-zero integer as capacity,
or another instance of the PhpExtended\Model\IntegerCapacityInterface.
A resolver is also provided to unserialize the data given by the __toString()
method that may be used with integer capacities.
use PhpExtended\Model\IntegerCapacityResolver;
$resolver = new IntegerCapacityResolver();
$capacity = $resolver->resolveCapacity('8 bits');
// $capacity is now a BitIntegerCapacity with 8 as bit value.
License
MIT (See license file).
统计信息
- 总下载量: 7.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-15