Skip to content

Commit

Permalink
Merge pull request #75 from norzechowicz/cleanup
Browse files Browse the repository at this point in the history
Cleanup before stable release
  • Loading branch information
Norbert Orzechowicz committed Jan 26, 2016
2 parents 6ec963f + 8741813 commit f5831e3
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 2.0

* Added support for PHP7
* Updated dependencies to support Symfony3 components
* Added support for Ordinal number strategies that require prefixes
9 changes: 9 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Upgrade 1.0 to 2.0

* All classes are now marked as final in order to close extra extension points
* Renamed ``Coduo\PHPHumanizer\Collection`` into ``Coduo\PHPHumanizer\CollectionHumanizer``
* Renamed ``Coduo\PHPHumanizer\DateTime`` into ``Coduo\PHPHumanizer\DateTimeHumanizer``
* Renamed ``Coduo\PHPHumanizer\Number`` into ``Coduo\PHPHumanizer\NumberHumanizer``
* Renamed ``Coduo\PHPHumanizer\String`` into ``Coduo\PHPHumanizer\StringHumanizer``
* Replaced ``ordinalSuffix($number)`` method in ``Coduo\PHPHumanizer\Number\Ordinal\StrategyInterface`` with ``isPrefix()`` and ``ordinalIndicator($number)``
* Dependency ``thunderer/shortcode`` was removed, now shortcode lib needs to be added to project
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"symfony/intl": "^2.3|^3.0",
"symfony/config": "^2.3|^3.0",
"symfony/translation": "^2.3|^3.0",
"symfony/yaml": "^2.3|^3.0",
"thunderer/shortcode": "~0.5"
"symfony/yaml": "^2.3|^3.0"
},
"require-dev": {
"thunderer/shortcode": "~0.5",
"phpspec/phpspec": "^2",
"phpunit/phpunit": "^4.5|^5.0"
},
Expand Down
8 changes: 4 additions & 4 deletions src/Coduo/PHPHumanizer/Number/Ordinal/StrategyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

interface StrategyInterface
{
/**
* @return boolean
*/
public function isPrefix();
/**
* @return boolean
*/
public function isPrefix();

/**
* @param int|float $number
Expand Down
7 changes: 3 additions & 4 deletions src/Coduo/PHPHumanizer/NumberHumanizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ final class NumberHumanizer
public static function ordinalize($number, $locale = 'en')
{
$ordinal = new Ordinal($number, $locale);
if ($ordinal->isPrefix()) {
return (string) $ordinal.$number;
}
else return (string) $number.$ordinal;

return (string) ($ordinal->isPrefix()) ? $ordinal.$number : $number.$ordinal;
}

/**
Expand All @@ -33,6 +31,7 @@ public static function ordinalize($number, $locale = 'en')
public static function ordinal($number, $locale = 'en')
{
$ordinal = new Ordinal($number, $locale);

return (string) $ordinal;
}

Expand Down
15 changes: 10 additions & 5 deletions src/Coduo/PHPHumanizer/Resources/Ordinal/EnStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,22 @@

final class EnStrategy implements StrategyInterface
{
/** {@inheritdoc}*/
public function isPrefix(){
return False;
/**
* {@inheritdoc}
*/
public function isPrefix()
{
return false;
}

/** {@inheritdoc} */
/**
* {@inheritdoc}
*/
public function ordinalIndicator($number)
{
$absNumber = abs((integer) $number);

if (in_array(($absNumber % 100), array(11, 12, 13))) {
if (in_array(($absNumber % 100), array(11, 12, 13), true)) {
return 'th';
}

Expand Down
15 changes: 10 additions & 5 deletions src/Coduo/PHPHumanizer/Resources/Ordinal/IdStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@

final class IdStrategy implements StrategyInterface
{
/** {@inheritdoc}*/
public function isPrefix(){
return True;
/**
* {@inheritdoc}
*/
public function isPrefix()
{
return true;
}

/** {@inheritdoc} */

/**
* {@inheritdoc}
*/
public function ordinalIndicator($number)
{
return 'ke-';
Expand Down
11 changes: 8 additions & 3 deletions src/Coduo/PHPHumanizer/Resources/Ordinal/NlStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@

final class NlStrategy implements StrategyInterface
{
/** {@inheritdoc}*/
public function isPrefix(){
/**
* {@inheritdoc}
*/
public function isPrefix()
{
return False;
}

/** {@inheritdoc} */
/**
* {@inheritdoc}
*/
public function ordinalIndicator($number)
{
return 'e';
Expand Down
8 changes: 8 additions & 0 deletions src/Coduo/PHPHumanizer/StringHumanizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public static function truncateHtml($text, $charactersCount, $allowedTags = '',
*/
public static function removeShortcodes($text)
{
if (!class_exists('Thunder\Shortcode\Processor\Processor')) {
throw new \RuntimeException("Please add \"thunderer/shortcode\": ~0.5 to composer.json first");
}

$processor = new ShortcodeProcessor();

return $processor->removeShortcodes($text);
Expand All @@ -69,6 +73,10 @@ public static function removeShortcodes($text)
*/
public static function removeShortcodeTags($text)
{
if (!class_exists('Thunder\Shortcode\Processor\Processor')) {
throw new \RuntimeException("Please add \"thunderer/shortcode\": ~0.5 to composer.json first");
}

$processor = new ShortcodeProcessor();

return $processor->removeShortcodeTags($text);
Expand Down

0 comments on commit f5831e3

Please sign in to comment.