Skip to content

Commit d4b3f03

Browse files
authored
Rewrote the cycle function & Fixed syntax
1 parent e49e196 commit d4b3f03

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

decorator.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,28 @@ class Decorator {
77
private $origin;
88

99
function __construct(){
10-
$upper = range('A', 'Z');
11-
$lower = range('a', 'z');
12-
$nums = range('0','9');
13-
$origin = $lower + $upper + $nums;
10+
$this->upper = range('A', 'Z');
11+
$this->lower = range('a', 'z');
12+
$this->nums = range('0','9');
13+
$this->origin = array_merge($this->lower, $this->upper, $this->nums);
1414
}
1515

1616
public function cycle($text){
17-
$id_upper = range(9398,9423);
18-
$id_lower = range(9324,9449);
19-
$id_nums = [9450] + range(9312,9320);
20-
$id = $id_lower + $id_upper + $id_nums;
21-
$map = [];
17+
$id_upper = range(hexdec('24B6'),hexdec('24CF'));
18+
$id_lower = range(hexdec('24D0'),hexdec('24E9'));
19+
$id_nums = array_merge([hexdec('24EA')],range(hexdec('2460'),hexdec('2468')));
20+
$id = array_merge($id_lower, $id_upper, $id_nums);
21+
foreach($id as $key => $val){
22+
$id[$key] = dechex($val);
23+
}
24+
$map = array();
2225
foreach($id as $val)
2326
{
2427
$myval = "\u{$val}";
25-
$myval = json_decode($myval);
26-
$map = $map + [$myval];
28+
$myval = json_decode('"'.$myval.'"');
29+
array_push($map, $myval);
2730
}
28-
return str_replace($original, $map, $text);
31+
return str_replace($this->origin, $map, $text);
2932
}
3033
}
3134

0 commit comments

Comments
 (0)