diff --git a/src/Coduo/PHPHumanizer/Number/Ordinal.php b/src/Coduo/PHPHumanizer/Number/Ordinal.php index c507951..e948eed 100644 --- a/src/Coduo/PHPHumanizer/Number/Ordinal.php +++ b/src/Coduo/PHPHumanizer/Number/Ordinal.php @@ -26,11 +26,11 @@ public function __construct($number, $locale) $this->number = $number; $this->strategy = Builder::build($locale); } - + public function __toString() { return $this ->strategy ->ordinalSuffix($this->number); } -} +} \ No newline at end of file diff --git a/src/Coduo/PHPHumanizer/NumberHumanizer.php b/src/Coduo/PHPHumanizer/NumberHumanizer.php index ab92ecd..173b727 100644 --- a/src/Coduo/PHPHumanizer/NumberHumanizer.php +++ b/src/Coduo/PHPHumanizer/NumberHumanizer.php @@ -1,12 +1,9 @@ convert(); } - /** * @param $number * @param $precision @@ -54,10 +46,8 @@ public static function binarySuffix($number, $locale = 'en') public static function preciseBinarySuffix($number, $precision, $locale = 'en') { $binarySuffix = new BinarySuffix($number, $locale, $precision); - return $binarySuffix->convert(); } - /** * @param $number * @param string $locale @@ -66,10 +56,8 @@ public static function preciseBinarySuffix($number, $precision, $locale = 'en') public static function metricSuffix($number, $locale = 'en') { $binarySuffix = new MetricSuffix($number, $locale); - return $binarySuffix->convert(); } - /** * @param $number * @return string @@ -77,10 +65,8 @@ public static function metricSuffix($number, $locale = 'en') public static function toRoman($number) { $romanNumeral = new RomanNumeral(); - return $romanNumeral->toRoman($number); } - /** * @param $number * @return int @@ -88,7 +74,6 @@ public static function toRoman($number) public static function fromRoman($number) { $romanNumeral = new RomanNumeral(); - return $romanNumeral->fromRoman($number); } -} +} \ No newline at end of file diff --git a/tests/Coduo/PHPHumanizer/Tests/NumberHumanizerTest.php b/tests/Coduo/PHPHumanizer/Tests/NumberHumanizerTest.php index 9377b9e..e749330 100644 --- a/tests/Coduo/PHPHumanizer/Tests/NumberHumanizerTest.php +++ b/tests/Coduo/PHPHumanizer/Tests/NumberHumanizerTest.php @@ -1,9 +1,6 @@ assertEquals($expected, NumberHumanizer::ordinal($number)); } - /** * @dataProvider ordinalSuffixDutchProvider * @param $expected @@ -26,7 +22,6 @@ public function test_return_ordinal_suffix_dutch($expected, $number) { $this->assertEquals($expected, NumberHumanizer::ordinal($number, 'nl')); } - /** * @dataProvider ordinalizeDataProvider * @depends test_return_ordinal_suffix @@ -38,7 +33,6 @@ public function test_ordinalize_numbers($expected, $number) { $this->assertEquals($expected, NumberHumanizer::ordinalize($number)); } - /** * @dataProvider ordinalizeDataDutchProvider * @depends test_return_ordinal_suffix_dutch @@ -50,7 +44,6 @@ public function test_ordinalize_numbers_dutch($expected, $number) { $this->assertEquals($expected, NumberHumanizer::ordinalize($number, 'nl')); } - /** * @dataProvider binarySuffixDataProvider * @@ -62,7 +55,6 @@ public function test_convert_number_to_string_with_binary_suffix($expected, $num { $this->assertEquals($expected, NumberHumanizer::binarySuffix($number, $locale)); } - /** * @expectedException \InvalidArgumentException */ @@ -70,7 +62,6 @@ public function test_statically_throw_exception_when_converting_to_string_with_b { NumberHumanizer::binarySuffix('as12'); } - /** * @dataProvider preciseBinarySuffixDataProvider * @@ -83,7 +74,6 @@ public function test_convert_number_to_string_with_precise_binary_suffix($expect { $this->assertEquals($expected, NumberHumanizer::preciseBinarySuffix($number, $precision, $locale)); } - /** * @expectedException \InvalidArgumentException */ @@ -91,7 +81,6 @@ public function test_statically_throw_exception_when_converting_to_string_with_p { NumberHumanizer::preciseBinarySuffix(1, -1); } - /** * @expectedException \InvalidArgumentException */ @@ -99,7 +88,6 @@ public function test_statically_throw_exception_when_converting_to_string_with_p { NumberHumanizer::preciseBinarySuffix(1, 4); } - /** * @dataProvider metricSuffixDataProvider * @@ -111,7 +99,6 @@ public function test_convert_number_to_string_with_metric_suffix($expected, $num { $this->assertEquals($expected, NumberHumanizer::metricSuffix($number, $locale)); } - /** * @expectedException \InvalidArgumentException */ @@ -119,7 +106,6 @@ public function test_statically_throw_exception_when_converting_to_string_with_m { NumberHumanizer::metricSuffix('as12'); } - /** * @dataProvider romanDataProvider * @@ -130,7 +116,6 @@ public function test_converts_numbers_to_roman($expected, $number) { $this->assertEquals($expected, NumberHumanizer::toRoman($number)); } - /** * @dataProvider romanDataProvider * @@ -141,7 +126,6 @@ public function test_convert_roman_numbers_to_arabic($number, $expected) { $this->assertEquals($expected, NumberHumanizer::fromRoman($number)); } - /** * @dataProvider romanExceptionProvider * @expectedException \InvalidArgumentException @@ -152,7 +136,6 @@ public function test_statically_throw_exception_when_converting_number_is_out_of { NumberHumanizer::toRoman($number); } - /** * @dataProvider arabicExceptionProvider * @expectedException \InvalidArgumentException @@ -163,7 +146,6 @@ public function test_statically_throw_exception_when_converting_roman_number_is_ { NumberHumanizer::fromRoman($number); } - /** * @return array */ @@ -177,7 +159,6 @@ public function ordinalizeDataProvider() array('-111th', -111), ); } - /** * @return array */ @@ -191,7 +172,6 @@ public function ordinalizeDataDutchProvider() array('-111e', -111), ); } - /** * @return array */ @@ -205,7 +185,6 @@ public function ordinalSuffixProvider() array('th', -111), ); } - /** * @return array */ @@ -219,7 +198,6 @@ public function ordinalSuffixDutchProvider() array('e', -111), ); } - /** * @return array */ @@ -236,12 +214,10 @@ public function binarySuffixDataProvider() array("2 GB", 1073741824 * 2), array("3 TB", 1099511627776 * 3), array("1.18 PB", 1325899906842624), - array("1,5 kB", 1536, 'pl'), array("1,18 PB", 1325899906842624, 'pl'), ); } - /** * @return array */ @@ -250,40 +226,32 @@ public function preciseBinarySuffixDataProvider() return array( // Negative case array(-1, -1, 3), - // Byte Cases array("0 bytes", 0, 3), array("1 bytes", 1, 0), array("1023 bytes", 1023, 3), - // Kilobyte Cases array('1.000 kB', 1024, 3), array("2 kB", 1588, 0), array("1.6 kB", 1588, 1), array("1.55 kB", 1588, 2), array("1.551 kB", 1588, 3), - // Megabyte Cases array("5.00 MB", (1048576 * 5), 2), array("5.00 MB", (1048576 * 5) + 600, 2), array("5.001 MB", (1048576 * 5) + 600, 3), - // Gigabyte Cases array("2 GB", 1073741824 * 2, 0), array("2.0 GB", 1073741824 * 2, 1), - // Terabyte Cases array("3.00 TB", 1099511627776 * 3, 2), - // Petabyte Case array("1.178 PB", 1325899906842624, 3), - // Locale Cases array("1,500 kB", 1536, 3, 'pl'), array("1,178 PB", 1325899906842624, 3, 'pl'), ); } - /** * @return array */ @@ -298,13 +266,11 @@ public function metricSuffixDataProvider() array("1.2k", 1240), array("1.24M", 1240000), array("3.5M", 3500000), - array("1,2k", 1240, 'pl'), array("1,24M", 1240000, 'pl'), array("3,5M", 3500000, 'pl'), ); } - /** * @return array */ @@ -320,7 +286,6 @@ public function romanDataProvider() array("MMMCMXCIX", 3999), ); } - /** * @return array */ @@ -331,7 +296,6 @@ public function romanExceptionProvider() array(4000), ); } - /** * @return array */ @@ -343,4 +307,4 @@ public function arabicExceptionProvider() array("foobar"), ); } -} +} \ No newline at end of file