pccomponentes / lexicographic-ranking
Lexicographic order calculator, useful for persisting ordered lists.
Installs: 3 470
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
Requires (Dev)
- pccomponentes/coding-standard: ^1.2
- phpro/grumphp: ^1.1
- phpstan/phpstan: ^0.12.55
- phpunit/phpunit: ^8.5
- symfony/var-dumper: ^5.1
README
Lexicographic order calculator, useful for persisting ordered lists.
Installation
Install via composer
composer require pccomponentes/lexicographic-ranking
Usage
$calculator = new RankingCalculator( new Alpha36TokenSet(), new DynamicMidPosition() ); echo $calculator->between('A', 'B'); // AU echo $calculator->between('F6', 'Z'); // P echo $calculator->between('FB', 'FW'); // FL echo $calculator->between(null, '7'); // 3 echo $calculator->between(null, null); // U
Config options
Token sets
The char pool to create the rankings. The following are available:
NumericTokenSet (0-9)
Alpha36TokenSet (0-9 and A-Z)
Alpha62TokenSet (0-9 and A-z)
To create a custom one extend from TokenSet.
Position
The space to be left between ranks. The following modes are available:
FixedStartPosition // Leaves a fixed amount of spaces after the first input
FixedEndPosition // Leaves a fixed amount of spaces before the second input
DynamicMidPosition // Leaves the same space before and after the result
To create a custom one implement Position.