Total Complexity | 4 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class Shortcode |
||
12 | { |
||
13 | protected static $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'; |
||
14 | |||
15 | public static function fromID($id) |
||
16 | { |
||
17 | $id = explode('_', $id)[0]; |
||
18 | $code = ''; |
||
19 | while ($id > 0) { |
||
20 | $remainder = $id % 64; |
||
21 | $id = ($id - $remainder) / 64; |
||
22 | $code = static::$chars{$remainder} . $code; |
||
23 | }; |
||
24 | |||
25 | return $code; |
||
26 | } |
||
27 | |||
28 | public static function toID($shortcode) |
||
37 | } |
||
38 | } |