Skip to content

Commit

Permalink
Merge pull request #10 from phpviet/analysis-GDLd42
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
vuongxuongminh authored Oct 16, 2021
2 parents e342e51 + acc0588 commit 1bfbcbc
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/Concerns/Collapse.php
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)
*/
Expand All @@ -9,6 +10,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.2.0
*/
trait Collapse
Expand All @@ -18,6 +20,7 @@ trait Collapse
*
* @param array|string[] $words
* @return string
*
* @since 1.2.0
*/
protected function collapseWords(array $words): string
Expand Down
4 changes: 3 additions & 1 deletion src/Concerns/NumberResolver.php
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)
*/
Expand All @@ -11,6 +12,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.0.5
*/
trait NumberResolver
Expand All @@ -20,6 +22,7 @@ trait NumberResolver
*
* @param int|float|string $number
* @return array
*
* @throws InvalidArgumentException
*/
protected function resolveNumber($number): array
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/Concerns/TripletTransformer.php
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)
*/
Expand All @@ -9,6 +10,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.0.0
*/
trait TripletTransformer
Expand Down
4 changes: 3 additions & 1 deletion src/Concerns/TripletsConverter.php
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)
*/
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/Dictionary.php
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)
*/
Expand All @@ -11,6 +12,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.0.0
*/
class Dictionary implements DictionaryInterface
Expand Down
10 changes: 6 additions & 4 deletions src/DictionaryInterface.php
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)
*/
Expand All @@ -9,6 +10,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.0.0
*/
interface DictionaryInterface
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/SouthDictionary.php
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)
*/
Expand All @@ -9,6 +10,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.0.0
*/
class SouthDictionary extends Dictionary
Expand Down
5 changes: 5 additions & 0 deletions src/Transformer.php
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)
*/
Expand All @@ -9,6 +10,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.0.0
*/
class Transformer
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tests/CurrencyTest.php
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)
*/
Expand All @@ -11,6 +12,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.0.0
*/
class CurrencyTest extends TestCase
Expand All @@ -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']));
}
Expand Down Expand Up @@ -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));
}

Expand Down
4 changes: 3 additions & 1 deletion tests/NumberTest.php
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)
*/
Expand All @@ -11,6 +12,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.0.0
*/
class NumberTest extends TestCase
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 2 additions & 0 deletions tests/SouthDictionaryTest.php
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)
*/
Expand All @@ -13,6 +14,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.0.0
*/
class SouthDictionaryTest extends BaseTestCase
Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase.php
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)
*/
Expand All @@ -12,6 +13,7 @@

/**
* @author Vuong Minh <[email protected]>
*
* @since 1.0.0
*/
class TestCase extends BaseTestCase
Expand Down

0 comments on commit 1bfbcbc

Please sign in to comment.