Skip to content

Commit 3f522f2

Browse files
committed
独立出执行转换过程
1 parent dae636b commit 3f522f2

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

MoneyConvertor.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,22 @@ public function convert($numberStr) {
7575
//判断是否为数字
7676
if (!is_numeric($numberStr))
7777
return '不是有效的货币数值';
78-
78+
79+
//执行转换
80+
self::convertor($numberStr);
81+
82+
//返回转换结果
83+
return $this->resultString;
84+
}
85+
86+
87+
/**
88+
* 执行转换
89+
* ---------------------------------------------------
90+
* @param $numberStr 将要转换的小写数字金额
91+
* @return void
92+
*/
93+
private function convertor($numberStr){
7994
//分差整数与浮点位,整数和小数部分分开,分别进行转换
8095
$cutedNumber = explode('.', (string)$numberStr);
8196

@@ -89,9 +104,9 @@ public function convert($numberStr) {
89104

90105
//去除无用零字符
91106
self::removeZero();
92-
93-
return $this->resultString;
94107
}
108+
109+
95110

96111
/**
97112
* 对整数部分进行转换

0 commit comments

Comments
 (0)