Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup before stable release #75

Merged
merged 1 commit into from
Jan 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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