isLessThan(BigInteger::fromBase('FFFFFFFFFFFFFFFF', 16)): return [27, self::hex2bin(static::fixHexLength(Utils::intToHex($length)))]; default: return [31, null]; } } private static function hex2bin(string $data): string { $result = hex2bin($data); if (false === $result) { throw new InvalidArgumentException('Unable to convert the data'); } return $result; } private static function fixHexLength(string $data): string { return str_pad($data, (int) (2 ** ceil(log(mb_strlen($data, '8bit'), 2))), '0', STR_PAD_LEFT); } }