Skip to content

Commit f5831e3

Browse files
author
Norbert Orzechowicz
committed
Merge pull request #75 from norzechowicz/cleanup
Cleanup before stable release
2 parents 6ec963f + 8741813 commit f5831e3

9 files changed

Lines changed: 59 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 2.0
2+
3+
* Added support for PHP7
4+
* Updated dependencies to support Symfony3 components
5+
* Added support for Ordinal number strategies that require prefixes

UPGRADE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Upgrade 1.0 to 2.0
2+
3+
* All classes are now marked as final in order to close extra extension points
4+
* Renamed ``Coduo\PHPHumanizer\Collection`` into ``Coduo\PHPHumanizer\CollectionHumanizer``
5+
* Renamed ``Coduo\PHPHumanizer\DateTime`` into ``Coduo\PHPHumanizer\DateTimeHumanizer``
6+
* Renamed ``Coduo\PHPHumanizer\Number`` into ``Coduo\PHPHumanizer\NumberHumanizer``
7+
* Renamed ``Coduo\PHPHumanizer\String`` into ``Coduo\PHPHumanizer\StringHumanizer``
8+
* Replaced ``ordinalSuffix($number)`` method in ``Coduo\PHPHumanizer\Number\Ordinal\StrategyInterface`` with ``isPrefix()`` and ``ordinalIndicator($number)``
9+
* Dependency ``thunderer/shortcode`` was removed, now shortcode lib needs to be added to project

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"symfony/intl": "^2.3|^3.0",
1919
"symfony/config": "^2.3|^3.0",
2020
"symfony/translation": "^2.3|^3.0",
21-
"symfony/yaml": "^2.3|^3.0",
22-
"thunderer/shortcode": "~0.5"
21+
"symfony/yaml": "^2.3|^3.0"
2322
},
2423
"require-dev": {
24+
"thunderer/shortcode": "~0.5",
2525
"phpspec/phpspec": "^2",
2626
"phpunit/phpunit": "^4.5|^5.0"
2727
},

src/Coduo/PHPHumanizer/Number/Ordinal/StrategyInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
interface StrategyInterface
66
{
7-
/**
8-
* @return boolean
9-
*/
10-
public function isPrefix();
7+
/**
8+
* @return boolean
9+
*/
10+
public function isPrefix();
1111

1212
/**
1313
* @param int|float $number

src/Coduo/PHPHumanizer/NumberHumanizer.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ final class NumberHumanizer
1818
public static function ordinalize($number, $locale = 'en')
1919
{
2020
$ordinal = new Ordinal($number, $locale);
21-
if ($ordinal->isPrefix()) {
22-
return (string) $ordinal.$number;
23-
}
24-
else return (string) $number.$ordinal;
21+
22+
return (string) ($ordinal->isPrefix()) ? $ordinal.$number : $number.$ordinal;
2523
}
2624

2725
/**
@@ -33,6 +31,7 @@ public static function ordinalize($number, $locale = 'en')
3331
public static function ordinal($number, $locale = 'en')
3432
{
3533
$ordinal = new Ordinal($number, $locale);
34+
3635
return (string) $ordinal;
3736
}
3837

src/Coduo/PHPHumanizer/Resources/Ordinal/EnStrategy.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@
66

77
final class EnStrategy implements StrategyInterface
88
{
9-
/** {@inheritdoc}*/
10-
public function isPrefix(){
11-
return False;
9+
/**
10+
* {@inheritdoc}
11+
*/
12+
public function isPrefix()
13+
{
14+
return false;
1215
}
1316

14-
/** {@inheritdoc} */
17+
/**
18+
* {@inheritdoc}
19+
*/
1520
public function ordinalIndicator($number)
1621
{
1722
$absNumber = abs((integer) $number);
1823

19-
if (in_array(($absNumber % 100), array(11, 12, 13))) {
24+
if (in_array(($absNumber % 100), array(11, 12, 13), true)) {
2025
return 'th';
2126
}
2227

src/Coduo/PHPHumanizer/Resources/Ordinal/IdStrategy.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66

77
final class IdStrategy implements StrategyInterface
88
{
9-
/** {@inheritdoc}*/
10-
public function isPrefix(){
11-
return True;
9+
/**
10+
* {@inheritdoc}
11+
*/
12+
public function isPrefix()
13+
{
14+
return true;
1215
}
13-
14-
/** {@inheritdoc} */
16+
17+
/**
18+
* {@inheritdoc}
19+
*/
1520
public function ordinalIndicator($number)
1621
{
1722
return 'ke-';

src/Coduo/PHPHumanizer/Resources/Ordinal/NlStrategy.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66

77
final class NlStrategy implements StrategyInterface
88
{
9-
/** {@inheritdoc}*/
10-
public function isPrefix(){
9+
/**
10+
* {@inheritdoc}
11+
*/
12+
public function isPrefix()
13+
{
1114
return False;
1215
}
1316

14-
/** {@inheritdoc} */
17+
/**
18+
* {@inheritdoc}
19+
*/
1520
public function ordinalIndicator($number)
1621
{
1722
return 'e';

src/Coduo/PHPHumanizer/StringHumanizer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public static function truncateHtml($text, $charactersCount, $allowedTags = '',
5858
*/
5959
public static function removeShortcodes($text)
6060
{
61+
if (!class_exists('Thunder\Shortcode\Processor\Processor')) {
62+
throw new \RuntimeException("Please add \"thunderer/shortcode\": ~0.5 to composer.json first");
63+
}
64+
6165
$processor = new ShortcodeProcessor();
6266

6367
return $processor->removeShortcodes($text);
@@ -69,6 +73,10 @@ public static function removeShortcodes($text)
6973
*/
7074
public static function removeShortcodeTags($text)
7175
{
76+
if (!class_exists('Thunder\Shortcode\Processor\Processor')) {
77+
throw new \RuntimeException("Please add \"thunderer/shortcode\": ~0.5 to composer.json first");
78+
}
79+
7280
$processor = new ShortcodeProcessor();
7381

7482
return $processor->removeShortcodeTags($text);

0 commit comments

Comments
 (0)