php-extended / php-integer-capacity-object
A library that implements the php-extended/php-integer-capacity-interface package
Requires
- php: >=8.0
- php-extended/php-integer-capacity-interface: ^7
Requires (Dev)
- dev-master
- 7.0.7
- 7.0.6
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.0.7
- 6.0.6
- 6.0.5
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.0.1
- 5.0.0
- 4.3.2
- 4.3.1
- 4.3.0
- 4.2.24
- 4.2.23
- 4.2.22
- 4.2.21
- 4.2.20
- 4.2.19
- 4.2.18
- 4.2.17
- 4.2.16
- 4.2.15
- 4.2.14
- 4.2.13
- 4.2.12
- 4.2.11
- 4.2.10
- 4.2.9
- 4.2.8
- 4.2.7
- 4.2.6
- 4.2.5
- 4.2.4
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.0
- 3.0.0
- 2.0.0
- 1.0.0
This package is auto-updated.
Last update: 2024-12-08 17:24:45 UTC
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.phar
from their website. - Then run the following command to install this library as dependency :
php composer.phar php-extended/php-integer-capacity-object ^7
Basic Usage
This library provides 4 classes to specify integer capacities from different containers.
- The
BitIntegerCapacity
class uses bits to count the capacity of integers - The
ByteIntegerCapacity
class uses 8-bits bytes to count the capacity of integers - The
StringIntegerCapacity
class uses decimal digits arranged in a string to count the capacity of integers - The
HexaIntegerCapacity
class 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).