kartik\helpers\Enum::convertTri PHP 메소드

convertTri() 보호된 정적인 메소드

Recursive function used in number to words conversion. Converts three digits per pass.
protected static convertTri ( double $num, integer $tri ) : string
$num double the source number
$tri integer the three digits converted per pass.
리턴 string
    protected static function convertTri($num, $tri)
    {
        // chunk the number ...xyz
        $x = (int) ($num / 1000);
        $y = $num / 100 % 10;
        $z = $num % 100;
        // init the output string
        $str = "";
        $ones = static::ones();
        $tens = static::tens();
        $triplets = static::triplets();
        // do hundreds
        if ($y > 0) {
            $str = $ones[$y] . ' ' . Yii::t('kvenum', 'hundred');
        }
        // do ones and tens
        $str .= $z < 20 ? $ones[$z] : $tens[(int) ($z / 10)] . $ones[$z % 10];
        // add triplet modifier only if there is some output to be modified...
        if ($str != "") {
            $str .= $triplets[$tri];
        }
        // recursively process until valid thousands digit found
        return $x > 0 ? static::convertTri($x, $tri + 1) . $str : $str;
    }