1 | <?php |
||
5 | class UniqueUid |
||
6 | { |
||
7 | static $charSet; |
||
8 | static $maxCharLen; |
||
9 | |||
10 | public function __construct() |
||
15 | |||
16 | /** |
||
17 | * set custom charset for the Unique ID |
||
18 | * |
||
19 | * @param string $characters |
||
20 | * @return void |
||
21 | */ |
||
22 | public function setCharSet($characters) |
||
27 | |||
28 | /** |
||
29 | * Set charset Len |
||
30 | * |
||
31 | * @param string $characters |
||
32 | * @return void |
||
33 | */ |
||
34 | public function setCharLen($characters) |
||
38 | |||
39 | /** |
||
40 | * TO the the Code Point form the Character set |
||
41 | * |
||
42 | * @param string $character |
||
43 | * @return integer |
||
44 | */ |
||
45 | public static function CodePointFromCharacter($character) |
||
50 | |||
51 | /** |
||
52 | * Get the Character set form the Code Point |
||
53 | * |
||
54 | * @param integer $codePoint |
||
55 | * @return string |
||
56 | */ |
||
57 | public static function CharacterFromCodePoint($codePoint) |
||
62 | |||
63 | /** |
||
64 | * Get the number of Valid characters for Check digit |
||
65 | * |
||
66 | * @return void |
||
67 | */ |
||
68 | public static function NumberOfValidCharacters() |
||
72 | |||
73 | /** |
||
74 | * This function will pass values to random generator. |
||
75 | * Our function has 1 digit to 25 options |
||
76 | * @length integer - length of expected |
||
77 | * @split integer - split range |
||
78 | * @return string |
||
79 | **/ |
||
80 | public static function getUniqueAlphanumeric(int $length = 9, int $split = 3) |
||
96 | |||
97 | /** |
||
98 | * Format the ID with given split range |
||
99 | * |
||
100 | * @param string $token |
||
101 | * @return integer |
||
102 | */ |
||
103 | public static function format(string $token, int $split) |
||
113 | |||
114 | /** |
||
115 | * Check the valid ID |
||
116 | * |
||
117 | * @param string $token |
||
118 | * @return boolean |
||
119 | */ |
||
120 | public static function isValidUniqueId(string $token, $validLength = 9, $split = 3) |
||
163 | |||
164 | /** |
||
165 | * Luhn mod N algorithm |
||
166 | * @input string $token |
||
167 | * @return string |
||
168 | **/ |
||
169 | public static function GenerateCheckCharacter(string $token) |
||
196 | } |
||
197 |