1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-24 01:09:50 +01:00

Updated sentence and paragraph methods + Removed trailing spaces

This commit is contained in:
Geoffrey Brier 2012-05-25 16:44:14 +02:00
parent a6589c64c3
commit 8f5575cd55

View File

@ -15,7 +15,7 @@ class Lorem extends \Faker\Provider\Base
{
return static::randomElement(static::$wordList);
}
/**
* Generate an array of random words
*
@ -31,7 +31,7 @@ class Lorem extends \Faker\Provider\Base
}
return $words;
}
/**
* Generate a random sentence
*
@ -41,12 +41,17 @@ class Lorem extends \Faker\Provider\Base
*/
public static function sentence($nbWords = 6)
{
if ($nbWords <= 0) {
return '';
} else {
$nbWords = ($nbWords * mt_rand(60, 140) / 100) + 1;
}
$words = static::words($nbWords + mt_rand(-2, 2));
$words[0] = ucwords($words[0]);
return join($words, ' ') . '.';
}
/**
* Generate an array of sentences
*
@ -62,7 +67,7 @@ class Lorem extends \Faker\Provider\Base
}
return $sentences;
}
/**
* Generate a single paragraph
*
@ -72,9 +77,14 @@ class Lorem extends \Faker\Provider\Base
*/
public static function paragraph($nbSentences = 3)
{
if ($nbSentences <= 0) {
return '';
} else {
$nbSentences = ($nbSentences * mt_rand(60, 140) / 100) + 1;
}
return join(static::sentences($nbSentences + mt_rand(-1, 1)), ' ');
}
/**
* Generate an array of paragraphs
*