/** * RfcIntConverter is a helper class to convert from an integer to RFC and backwards. * It should be used with well known string expressions: upper case and be valid according to RFC rules. * * The integer value is a 64-bit integer, goes from 0 to 332,162,701,516,799. * It can be stored in a PHP integer, mysql big int, sqlite int, etc. * * The way to transform the string to integer is splitting the contents into 9 parts with different bases: * | optional name | 3 x required name | day since 2000 | 2 x homoclave | checksum | * | base 29 | base 28 | base 36525 | base 36 | base 11 | * Rfc COSC8001137NA will be: [3, 14, 18, 2, 416731392, 33, 23, 10] `=>` 40,270,344,269,627 * To transform from the integer representation it gets modulus for each base and retrieve the 9 integer parts: * 40,270,344,269,627 will be: [3, 14, 18, 2, 416731392, 33, 23, 10], then will convert each part to its strings. */ export default class RfcIntConverter { static readonly MIN_INTEGER_VALUE = 0; static readonly MAX_INTEGER_VALUE: number; static readonly FISICA_LOWER_BOUND = 11430415180800; static readonly FISICA_UPPER_BOUND: number; static readonly MORAL_LOWER_BOUND = 0; static readonly MORAL_UPPER_BOUND: number; private readonly BASES; private readonly EXP; private readonly CSUM_INT_CHAR; private readonly CSUM_CHAR_INT; private readonly HKEY_INT_CHAR; private readonly HKEY_CHAR_INT; private readonly NAME_REQ_INT_CHAR; private readonly NAME_REQ_CHAR_INT; private readonly NAME_OPT_INT_CHAR; private readonly NAME_OPT_CHAR_INT; /** * Convert a valid uppercase RFC string expression to integer, * * Be aware that if provide malformed RFC will return an integer, but it might not be able to convert it back. * * @param rfc - */ stringToInt(rfc: string): number; /** * Convert an integer expression to a valid RFC string expression. * * @param value - * @throws InvalidIntegerToConvertException if value is lower than zero or greater than maximum value */ intToString(value: number): string; protected strDateToInt(value: string): number; protected intTostrDate(value: number): string; }