@@ -13,17 +13,17 @@ discard block |
||
13 | 13 | { |
14 | 14 | private $money; |
15 | 15 | |
16 | - private $uppers = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']; |
|
16 | + private $uppers = [ '零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖' ]; |
|
17 | 17 | |
18 | - private $units = ['分', '角']; |
|
18 | + private $units = [ '分', '角' ]; |
|
19 | 19 | |
20 | - private $grees = ['元', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟', '万', '拾', '佰']; |
|
20 | + private $grees = [ '元', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟', '万', '拾', '佰' ]; |
|
21 | 21 | |
22 | 22 | private $thanOne = false; |
23 | 23 | |
24 | 24 | public function __construct($money) |
25 | 25 | { |
26 | - if (!(is_float($money) || is_numeric($money) || is_int($money))) { |
|
26 | + if ( ! (is_float($money) || is_numeric($money) || is_int($money))) { |
|
27 | 27 | throw new \InvalidArgumentException($money); |
28 | 28 | } |
29 | 29 | if ($money > 1) { |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | $gree = strlen($intPart) - 1; |
56 | 56 | if ($intPart > 0) { |
57 | 57 | for ($i = 0; $i < strlen($intPart); ++$i) { |
58 | - $num = $intPart[$i]; |
|
59 | - $result .= $this->uppers[$num].$this->grees[$gree--]; |
|
58 | + $num = $intPart[ $i ]; |
|
59 | + $result .= $this->uppers[ $num ] . $this->grees[ $gree -- ]; |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | //处理小数部分 |
85 | 85 | $unit = strlen($decimalPart) - 1; |
86 | 86 | for ($i = 0; $i < strlen($decimalPart); ++$i) { |
87 | - $num = $decimalPart[$i]; |
|
88 | - $result .= $this->uppers[$num].$this->units[$unit--]; |
|
87 | + $num = $decimalPart[ $i ]; |
|
88 | + $result .= $this->uppers[ $num ] . $this->units[ $unit -- ]; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | $result = str_replace('零分', '', $result); |