-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from phpviet/analysis-GDLd42
Apply fixes from StyleCI
- Loading branch information
Showing
12 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -9,6 +10,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
trait Collapse | ||
|
@@ -18,6 +20,7 @@ trait Collapse | |
* | ||
* @param array|string[] $words | ||
* @return string | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
protected function collapseWords(array $words): string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -11,6 +12,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.5 | ||
*/ | ||
trait NumberResolver | ||
|
@@ -20,6 +22,7 @@ trait NumberResolver | |
* | ||
* @param int|float|string $number | ||
* @return array | ||
* | ||
* @throws InvalidArgumentException | ||
*/ | ||
protected function resolveNumber($number): array | ||
|
@@ -28,7 +31,6 @@ protected function resolveNumber($number): array | |
throw new InvalidArgumentException(sprintf('Number arg (`%s`) must be numeric!', $number)); | ||
} | ||
|
||
|
||
if ($this->decimalPart === null) { | ||
$number += 0; // trick xóa các số 0 lẻ sau cùng của phân số đối với input là chuỗi. | ||
$number = (string) $number; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -9,6 +10,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
trait TripletTransformer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -9,14 +10,15 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
trait TripletsConverter | ||
{ | ||
/** | ||
* Chia số truyền vào thành các cụm gồm 3 số để hổ trợ cho việc chuyển sang chữ số. | ||
* | ||
* @param int $number | ||
* @param int $number | ||
* @return array|int[] | ||
*/ | ||
protected function numberToTriplets(int $number): array | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -11,6 +12,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class Dictionary implements DictionaryInterface | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -9,6 +10,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
interface DictionaryInterface | ||
|
@@ -72,31 +74,31 @@ public function tripletTenSeparator(): string; | |
/** | ||
* Trả về từ ngữ hàng đơn vị tương ứng với số truyền vào. | ||
* | ||
* @param int $unit hàng đơn vị | ||
* @param int $unit hàng đơn vị | ||
* @return string | ||
*/ | ||
public function getTripletUnit(int $unit): string; | ||
|
||
/** | ||
* Trả về từ ngữ hàng chục tương ứng với số truyền vào. | ||
* | ||
* @param int $ten hàng chục | ||
* @param int $ten hàng chục | ||
* @return string | ||
*/ | ||
public function getTripletTen(int $ten): string; | ||
|
||
/** | ||
* Trả về từ ngữ hàng trăm tương ứng với số truyền vào. | ||
* | ||
* @param int $hundred hàng trăm | ||
* @param int $hundred hàng trăm | ||
* @return string | ||
*/ | ||
public function getTripletHundred(int $hundred): string; | ||
|
||
/** | ||
* Trả về đơn vị tương ứng với số mũ cơ số 3. | ||
* | ||
* @param int $power hàng trăm | ||
* @param int $power hàng trăm | ||
* @return string | ||
*/ | ||
public function getExponent(int $power): string; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -9,6 +10,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class SouthDictionary extends Dictionary | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -9,6 +10,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class Transformer | ||
|
@@ -25,6 +27,7 @@ class Transformer | |
|
||
/** | ||
* Mặc định bỏ số các số 0 sau phần thập phân. | ||
* | ||
* @var int | ||
*/ | ||
protected $decimalPart; | ||
|
@@ -49,6 +52,7 @@ public function __construct(?DictionaryInterface $dictionary = null, $decimalPar | |
* | ||
* @param int|float|string $number | ||
* @return string | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function toWords($number): string | ||
|
@@ -82,6 +86,7 @@ public function toWords($number): string | |
* @param $number | ||
* @param array|string[]|string $unit | ||
* @return string | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function toCurrency($number, $unit = 'đồng'): string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -11,6 +12,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class CurrencyTest extends TestCase | ||
|
@@ -36,7 +38,7 @@ public function testUSDTransform($expect, $number) | |
*/ | ||
public function testUSDSetDecimalPart($expect, $float, $decimalPart) | ||
{ | ||
$transformer = new Transformer($this->dictionary, $decimalPart); | ||
$transformer = new Transformer($this->dictionary, $decimalPart); | ||
|
||
$this->assertEquals($expect, $transformer->toCurrency($float, ['đô', 'xen'])); | ||
} | ||
|
@@ -64,7 +66,7 @@ public function usdDecimalPartDataProvider(): array | |
*/ | ||
public function testSetDecimalPart($expect, $float, $decimalPart) | ||
{ | ||
$transformer = new Transformer($this->dictionary, $decimalPart); | ||
$transformer = new Transformer($this->dictionary, $decimalPart); | ||
$this->assertEquals($expect, $transformer->toCurrency($float)); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -11,6 +12,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class NumberTest extends TestCase | ||
|
@@ -44,7 +46,7 @@ public function testFractionTransform($expect, $float) | |
*/ | ||
public function testSetDecimalPart($expect, $float, $decimalPart) | ||
{ | ||
$transformer = new Transformer($this->dictionary, $decimalPart); | ||
$transformer = new Transformer($this->dictionary, $decimalPart); | ||
|
||
$this->assertEquals($expect, $transformer->toWords($float)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -13,6 +14,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class SouthDictionaryTest extends BaseTestCase | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/phpviet/number-to-words | ||
* | ||
* @copyright (c) PHP Viet | ||
* @license [MIT](http://www.opensource.org/licenses/MIT) | ||
*/ | ||
|
@@ -12,6 +13,7 @@ | |
|
||
/** | ||
* @author Vuong Minh <[email protected]> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class TestCase extends BaseTestCase | ||
|