@param int    $n
@param string $f1
@param string $f2
@param string $f5

@return string
973690
public function morph($n, $f1, $f2, $f5)
    {
        $n = abs((int) $n) % 100;
        if ($n > 10 && $n < 20) {
            return $f5;
        }
        $n = $n % 10;
        if ($n > 1 && $n < 5) {
            return $f2;
        }
        if ($n == 1) {
            return $f1;
        }

        return $f5;
    }
674516
static function gnameForRef($fname) {
		$refDefs = static::refDefs();
		$gname = $refDefs[$fname][static::GNAME];
		if ($gname === null) {
			throw new \Exception("Invalid fname `$fname` called for gnameForRef");
		}
		return $gname;
	}
874973
public function read($n, $offset = 0)
    {
        if ($this->length < $offset + $n) {
            throw new BufferUnderflowException();

        } elseif ($offset === 0 && $this->length === $offset + $n) {
            return $this->buffer;

        } else {
            return substr($this->buffer, $offset, $n);
        }
    }
1076396
private function base62toDec($n)
    {
        $n = preg_replace("/[^A-Za-z0-9 ]/", '', $n);
        $vals = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $vals = array_flip(str_split($vals));
        $out = 0;
        $len = strlen($n);
        for ($i = 0; $i < $len; $i++)
        {
            $c = $n[$len - ($i + 1)];
            $out += $vals[$c] * pow(62, $i);
        }

        return (int)$out;
    }
60652
public static function makeFileName($cnpj, $serie, $nnf, $ext, $modelo = '-Nfe')
    {
        $nome = $cnpj;
        $nome .= '_S' . str_pad($serie, 3, '0', STR_PAD_LEFT);
        $nome .= '_N' . str_pad($nnf, 9, '0', STR_PAD_LEFT);
        $nome .= $modelo . '.' . $ext;

        return $nome;
    }
867140
public static String multiply(String f1, String f2) {
        BigDecimal factor1;
        BigDecimal factor2;

        try {
            factor1 = new BigDecimal(f1);
            factor2 = new BigDecimal(f2);
        } catch (Exception ex) {
            return null;
        }

        return factor1.multiply(factor2).toString();
    }
257308
private function _argindex($n, $a)
    {
        $dashdash = 0;
        if (!is_array($a) || !count($a)) {
            return -1;
        }
        for ($i=1; $i < count($a); $i++) {
            if ($dashdash || !($a[$i][0] == '-' || $a[$i][0] == '+' || strchr($a[$i], '='))) {
                if ($n == 0) {
                    return $i;
                }
                $n--;
            }
            if ($_SERVER['argv'][$i] == '--') {
                $dashdash = 1;
            }
        }
        return -1;
    }
856395
function _PackFloat ( $f )
    {
        $t1 = pack ( "f", $f ); // machine order
        list(,$t2) = unpack ( "L*", $t1 ); // int in machine order
        return pack ( "N", $t2 );
    }
3113
public function execute($n)
    {
        $stack = array();
        $i = 0;
        $total = count($this->tokens);
        while ($i < $total) {
            $next = $this->tokens[$i];
            $i++;
            if ($next[0] === 'var') {
                $stack[] = $n;
                continue;
            } elseif ($next[0] === 'value') {
                $stack[] = $next[1];
                continue;
            }

            // Only operators left.
            switch ($next[1]) {
                case '%':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 % $v2;
                    break;

                case '||':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 || $v2;
                    break;

                case '&&':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 && $v2;
                    break;

                case '<':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 < $v2;
                    break;

                case '<=':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 <= $v2;
                    break;

                case '>':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 > $v2;
                    break;

                case '>=':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 >= $v2;
                    break;

                case '!=':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 != $v2;
                    break;

                case '==':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 == $v2;
                    break;

                case '?:':
                    $v3 = array_pop($stack);
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 ? $v2 : $v3;
                    break;

                default:
                    throw new Exception(sprintf('Unknown operator "%s"', $next[1]));
            }
        }

        if (count($stack) !== 1) {
            throw new Exception('Too many values remaining on the stack');
        }

        return (int) $stack[0];
    }
1373939
private function select_string($n) {
        $string = $this->get_plural_forms();
        $string = str_replace('nplurals', "\$total", $string);
        $string = str_replace("n", $n, $string);
        $string = str_replace('plural', "\$plural", $string);

        $total = 0;
        $plural = 0;

        eval("$string");
        if ($plural >= $total) $plural = $total - 1;
        return $plural;
    }
1134511
public function read($n)
    {
        if ($n <= 0) {
            return '';
        }
        if (!isset($this->bev)) {
            return false;
        }
        $read = $this->bev->read($n);
        if ($read === null) {
            return false;
        }
        return $read;
    }
1150375
public static function modulo10($n)
    {
        $chars = array_reverse(str_split($n, 1));
        $odd = array_intersect_key($chars, array_fill_keys(range(1, count($chars), 2), null));
        $even = array_intersect_key($chars, array_fill_keys(range(0, count($chars), 2), null));
        $even = array_map(
            function ($n) {
                return ($n >= 5) ? 2*$n - 9 : 2*$n;
            }, $even
        );
        $total = array_sum($odd) + array_sum($even);
        return ((floor($total/10) + 1)*10 - $total)%10;
    }
891689
public function doTransform($n = null)
    {
        // get the last Transformation Matrix
        $nb = count($this->_transf);
        if ($nb) {
            $m = $this->_transf[$nb-1];
        } else {
            $m = array(1,0,0,1,0,0);
        }

        // if no transform, get the Identity Matrix
        if (!$n) {
            $n = array(1,0,0,1,0,0);
        }

        // create the new Transformation Matrix
        $this->_transf[] = array(
            $m[0]*$n[0]+$m[2]*$n[1],
            $m[1]*$n[0]+$m[3]*$n[1],
            $m[0]*$n[2]+$m[2]*$n[3],
            $m[1]*$n[2]+$m[3]*$n[3],
            $m[0]*$n[4]+$m[2]*$n[5]+$m[4],
            $m[1]*$n[4]+$m[3]*$n[5]+$m[5]
        );
    }
1129384
public function decrypt($c, $d, $n)
    {
        $coded = split(' ', $c);
        $message = '';
        $max = count($coded);
        for ($i = 0; $i < $max; $i++) {
            $code = bcpowmod($coded[$i], $d, $n);
            while (bccomp($code, '0') != 0) {
                $ascii = bcmod($code, '256');
                $code = bcdiv($code, '256', 0);
                $message .= chr($ascii);
            }
        }

        return $message;
    }
177197
public function &offsetGet($n) {
        if(!$this->offsetExists($n)) {
            throw new IndexNotFoundException((string) $n);
        }
        return $this->data[$n];
    }
108226
private static function ord2charset($n) {
    if ($n >= 0 && $n <= 64) {
      return 'OTHER'; # ASCII not printable
    }
    elseif ($n >= 65 && $n <= 90) {
      return 'LATIN'; # LATIN-BASIC
    }
    elseif ($n >= 91 && $n <= 96) {
      return 'OTHER'; # ASCII not printable
    }
    elseif ($n >= 97 && $n <= 122) {
      return 'LATIN'; # LATIN-BASIC
    }
    elseif ($n >= 123 && $n <= 127) {
      return 'OTHER'; # ASCII not printable
    }
    elseif ($n >= 128 && $n <= 255) {
      return 'LATIN'; # LATIN-SUPPL
    }
    elseif ($n >= 256 && $n <= 383) {
      return 'LATIN'; # LATIN-EXT-A
    }
    elseif ($n >= 384 && $n <= 591) {
      return 'LATIN'; # LATIN-EXT-B
    }
    elseif ($n >= 880 && $n <= 1023) {
      return 'GREEK';
    }
    elseif ($n >= 1024 && $n <= 1279) {
      return 'CYRILLIC';
    }
    elseif ($n >= 1328 && $n <= 1423) {
      return 'ARMENIAN';
    }
    elseif ($n >= 1424 && $n <= 1535) {
      return 'HEBREW';
    }
    elseif ($n >= 1536 && $n <= 1791) {
      return 'ARABIC';
    }
    elseif ($n >= 2304 && $n <= 2431) {
      return 'DEVANAGARI';
    }
    elseif ($n >= 2432 && $n <= 2559) {
      return 'BENGALI';
    }
    elseif ($n >= 2688 && $n <= 2815) {
      return 'GUJARATI';
    }
    elseif ($n >= 2944 && $n <= 3071) {
      return 'TAMIL';
    }
    elseif ($n >= 3328 && $n <= 3455) {
      return 'MALAYALAM';
    }
    elseif ($n >= 3456 && $n <= 3583) {
      return 'SINHALA';
    }
    elseif ($n >= 3584 && $n <= 3711) {
      return 'THAI';
    }
    elseif ($n >= 3712 && $n <= 3839) {
      return 'LAO';
    }
    elseif ($n >= 3840 && $n <= 4095) {
      return 'TIBETAN';
    }
    elseif ($n >= 4096 && $n <= 4255) {
      return 'BURMESE';
    }
    elseif ($n >= 4256 && $n <= 4351) {
      return 'GEORGIAN';
    }
    elseif ($n >= 4352 && $n <= 4607) {
      return 'KOREAN'; # HANGUL-JAMO
    }
    elseif ($n >= 6016 && $n <= 6143) {
      return 'KHMER';
    }
    elseif ($n >= 7680 && $n <= 7935) {
      return 'LATIN'; # LATIN-EXT-ADDL
    }
    elseif ($n >= 7936 && $n <= 8191) {
      return 'GREEK'; # Greek Extended
    }
    elseif ($n >= 12288 && $n <= 12351) {
      return 'OTHER'; # CJK Punctuation
    }
    elseif ($n >= 12352 && $n <= 12447) {
      return 'JAPANESE'; # Hiragana
    }
    elseif ($n >= 12448 && $n <= 12543) {
      return 'JAPANESE'; # Katakana
    }
    elseif ($n >= 13312 && $n <= 19893) {
      return 'CJK'; # CJK Unified Ideographs Extension A
    }
    elseif ($n >= 19968 && $n <= 40959) {
      return 'CJK'; # CJK Unified Ideographs
    }
    elseif ($n >= 44032 && $n <= 55203) {
      return 'KOREAN'; # Hangul Syllables
    }
    return 'OTHER';
  }
1007547
public static function modulo11($n, $factor = 2, $base = 9, $x10 = 0, $resto10 = 0)
    {
        $sum = 0;
        for ($i = mb_strlen($n); $i > 0; $i--) {
            $sum += mb_substr($n, $i - 1, 1)*$factor;
            if ($factor == $base) {
                $factor = 1;
            }
            $factor++;
        }

        if ($x10 == 0) {
            $sum *= 10;
            $digito = $sum%11;
            if ($digito == 10) {
                $digito = $resto10;
            }
            return $digito;
        }
        return $sum%11;
    }