kwaadpepper / serial-int-caster
Convert int To as serial number and reverse
1.1.0
2022-12-11 00:45 UTC
Requires
- php: >=7.3.0
- ruafozy/mersenne-twister: ^1.3
Requires (Dev)
- phpunit/phpunit: ^9.5
- slevomat/coding-standard: ^8.6
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-10-13 10:11:25 UTC
README
This Library allows to encode an integer to a serial number and the other way around decode it to retrieve the integer.
Unit tests
Unit tests are available :
composer install
composer run test
Generate Kotlin test file
composer run generateList -- --lines=9999
To generate csv file to the kotlin unit tests put this file in its root folder and run unit tests.
https://github.com/Kwaadpepper/serial-int-caster-kotlin
Usage
composer install kwaadpepper/serial-int-caster
$int_to_encode = 15; $dictionnary = 'ABCDEFabcdef0123456789'; $seed = 1492; /** @var string $encoded_number ('1bzzzO') */ $encoded_number = SerialCaster::encode(number: $int_to_encode, seed: $seed, length: 6, chars: $dictionnary); /** @var integer $decoded_number (15) */ $decoded_number = SerialCaster::decode(serial: '1bzzzO', seed: $seed, chars: $dictionnary); /** Prints TRUE */ print_r($int_to_encode === $decoded_number);