@@ -28,31 +28,31 @@ public static function generate(?DateTimeInterface $dateTime = null): string
2828 {
2929 $ time = (int )($ dateTime ?? new DateTimeImmutable ('now ' ))->format ('Uv ' );
3030
31- $ isDuplicate = $ time === static ::$ lastGenTime ;
32- static ::$ lastGenTime = $ time ;
31+ $ isDuplicate = $ time === self ::$ lastGenTime ;
32+ self ::$ lastGenTime = $ time ;
3333
3434 // Generate time characters
3535 $ timeChars = '' ;
36- for ($ i = static ::$ timeLength - 1 ; $ i >= 0 ; $ i --) {
37- $ mod = $ time % static ::$ encodingLength ;
38- $ timeChars = static ::$ encodingChars [$ mod ] . $ timeChars ;
39- $ time = ($ time - $ mod ) / static ::$ encodingLength ;
36+ for ($ i = self ::$ timeLength - 1 ; $ i >= 0 ; $ i --) {
37+ $ mod = $ time % self ::$ encodingLength ;
38+ $ timeChars = self ::$ encodingChars [$ mod ] . $ timeChars ;
39+ $ time = ($ time - $ mod ) / self ::$ encodingLength ;
4040 }
4141
4242 // Generate random characters
4343 $ randChars = '' ;
4444 if (!$ isDuplicate ) {
45- for ($ i = 0 ; $ i < static ::$ randomLength ; $ i ++) {
46- static ::$ lastRandChars [$ i ] = random_int (0 , 31 );
45+ for ($ i = 0 ; $ i < self ::$ randomLength ; $ i ++) {
46+ self ::$ lastRandChars [$ i ] = random_int (0 , 31 );
4747 }
4848 } else {
49- for ($ i = static ::$ randomLength - 1 ; $ i >= 0 && static ::$ lastRandChars [$ i ] === 31 ; $ i --) {
50- static ::$ lastRandChars [$ i ] = 0 ;
49+ for ($ i = self ::$ randomLength - 1 ; $ i >= 0 && self ::$ lastRandChars [$ i ] === 31 ; $ i --) {
50+ self ::$ lastRandChars [$ i ] = 0 ;
5151 }
52- static ::$ lastRandChars [$ i ]++;
52+ self ::$ lastRandChars [$ i ]++;
5353 }
54- for ($ i = 0 ; $ i < static ::$ randomLength ; $ i ++) {
55- $ randChars .= static ::$ encodingChars [static ::$ lastRandChars [$ i ]];
54+ for ($ i = 0 ; $ i < self ::$ randomLength ; $ i ++) {
55+ $ randChars .= self ::$ encodingChars [self ::$ lastRandChars [$ i ]];
5656 }
5757
5858 return $ timeChars . $ randChars ;
@@ -67,19 +67,19 @@ public static function generate(?DateTimeInterface $dateTime = null): string
6767 */
6868 public static function getTime (string $ ulid ): DateTimeImmutable
6969 {
70- if (!static ::isValid ($ ulid )) {
70+ if (!self ::isValid ($ ulid )) {
7171 throw new ULIDException ('Invalid ULID string ' );
7272 }
7373
74- $ timeChars = str_split (strrev (substr ($ ulid , 0 , static ::$ timeLength )));
74+ $ timeChars = str_split (strrev (substr ($ ulid , 0 , self ::$ timeLength )));
7575
7676 $ time = 0 ;
7777 foreach ($ timeChars as $ index => $ char ) {
78- $ encodingIndex = strripos (static ::$ encodingChars , $ char );
79- $ time += ($ encodingIndex * static ::$ encodingLength ** $ index );
78+ $ encodingIndex = strripos (self ::$ encodingChars , $ char );
79+ $ time += ($ encodingIndex * self ::$ encodingLength ** $ index );
8080 }
8181
82- $ time = str_split ($ time , static ::$ timeLength );
82+ $ time = str_split ($ time , self ::$ timeLength );
8383
8484 if ($ time [0 ] > (time () + (86400 * 365 * 10 ))) {
8585 throw new ULIDException ('Invalid ULID string: timestamp too large ' );
0 commit comments