Commit c4aa6e6b authored by Taylor Otwell's avatar Taylor Otwell

consolidated plural and plural_if into single method.

parent 0cd6966e
......@@ -115,25 +115,31 @@ class Inflector {
);
/**
* Get the plural form of a word if the specified count is greater than one.
* Convert a word to its plural form.
*
* Optionally, a count argument may be provided. If the count is greater than
* one, the word will be pluralized, otherwise the word will be returned from
* the method unchanged.
*
* <code>
* // Get the plural form of the word "child"
* $children = Inflector::plural('child');
*
* // Returns "comments"
* $comments = Inflector::plural('comment', 10);
*
* // Returns "comment"
* $comment = Inflector::plural('comment', 1);
* </code>
*
* @param string $value
* @param int $count
* @return string
*/
public static function plural_if($value, $count)
public static function plural($value, $count = null)
{
return ($count > 1) ? static::plural($value) : $value;
}
if ( ! is_null($count) and $count <= 1) return $value;
/**
* Convert a word to its plural form.
*
* @param string $value
* @return string
*/
public static function plural($value)
{
$irregular = array_flip(static::$irregular);
$plural = static::inflect($value, static::$plural_cache, $irregular, static::$plural);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment