Download the PHP package requtize/semver-converter without Composer
On this page you can find all versions of the php package requtize/semver-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download requtize/semver-converter
More information about requtize/semver-converter
Files in requtize/semver-converter
Package semver-converter
Short Description Converts SemVer version (like Composer packages) into integer version with operators. Helps managing versions: store, compare, sort and retrive by conditions.
License MIT
Informations about the package semver-converter
SemVer Converter
Converts SemVer version (like Composer packages) into integer version with operators. Helps managing versions: store, compare, sort and retrive by conditions.
Converter accepts the same versions as Composer, so You can use it with any package manager that accepts Semantic Versioning.
How it works?
For each version it uses Composer SemVer parser to parse version and normalize it. And then, for each version, converter creates array exploded by dot values. Each value pads with zeros and create from it long string which is converted to integer. And for each version we have big integer.
Sample:
- Version 1.0.5
- Normalize with SemVer: 1.0.5
- Explode: [ 1, 0, 5 ]
- Converts to strings and pad zeros: [ '001', '000', '005' ]
- Concatenate all strings: '001' + '000' + '005'
- Converts to integer: (int) '1000005'
Result: '1.0.5' == 1000005
Examples
Simple version
Version between
Tilde operator
Version or
Settings
$zeros
Defines how meny zeros need to pad for each section of versions. It allows to define how long should be result.
$sections
Defines how many sections need to be generated from input. Default is 3, Composer SemVer generates 4. This also have an impact for result.
Licence
This code is licensed under MIT License.