private function getDecoder() { // returns a pattern used for fast decoding of the packed script $trim = new RegGrp(array('(\\d)(\\|\\d)+\\|(\\d)' => '$1-$3', '([a-z])(\\|[a-z])+\\|([a-z])' => '$1-$3', '([A-Z])(\\|[A-Z])+\\|([A-Z])' => '$1-$3', '\\|' => '')); $pattern = $trim->exec(implode('|', array_slice($this->words->map(array(&$this, '_word_replacement')), 0, 62))); if ($pattern == '') { return '^$'; } $pattern = '[' . $pattern . ']'; $size = $this->words->size(); if ($size > 62) { $pattern = '(' . $pattern . '|'; $encoded = Packer::encode62($size); $c = $encoded[0]; if ($c > '9') { $pattern .= '[\\\\d'; if ($c >= 'a') { $pattern .= 'a'; if ($c >= 'z') { $pattern .= '-z'; if ($c >= 'A') { $pattern .= 'A'; if ($c > 'A') { $pattern .= '-' . $c; } } } else { if ($c == 'b') { $pattern .= '-' . $c; } } } $pattern .= ']'; } else { if ($c == 9) { $pattern .= '\\\\d'; } else { if ($c == 2) { $pattern .= '[12]'; } else { if ($c == 1) { $pattern .= '1'; } else { $pattern .= '[1-' . $c . ']'; } } } } $pattern .= "\\\\w)"; } return $pattern; }
public static function _encoder($index) { return '_' . Packer::encode62($index); }