diff --git a/src/Faker/Provider/Lorem.php b/src/Faker/Provider/Lorem.php index 4fb115dc..99e25d89 100644 --- a/src/Faker/Provider/Lorem.php +++ b/src/Faker/Provider/Lorem.php @@ -57,15 +57,16 @@ class Lorem extends \Faker\Provider\Base * * @example array('Lorem', 'ipsum', 'dolor') * @param integer $nb how many words to return - * @return array + * @param bool $asText if true the sentences are returned as one string + * @return array|string */ - public static function words($nb = 3) + public static function words($nb = 3, $asText = false) { $words = array(); for ($i=0; $i < $nb; $i++) { $words []= static::word(); } - return $words; + return $asText ? join(' ', $words) : $words; } /** @@ -97,15 +98,16 @@ class Lorem extends \Faker\Provider\Base * * @example array('Lorem ipsum dolor sit amet.', 'Consectetur adipisicing eli.') * @param integer $nb how many sentences to return - * @return array + * @param bool $asText if true the sentences are returned as one string + * @return array|string */ - public static function sentences($nb = 3) + public static function sentences($nb = 3, $asText = false) { $sentences = array(); for ($i=0; $i < $nb; $i++) { $sentences []= static::sentence(); } - return $sentences; + return $asText ? join(' ', $sentences) : $sentences; } /** @@ -134,15 +136,16 @@ class Lorem extends \Faker\Provider\Base * * @example array($paragraph1, $paragraph2, $paragraph3) * @param integer $nb how many paragraphs to return - * @return array + * @param bool $asText if true the paragraphs are returned as one string, separated by two newlines + * @return array|string */ - public static function paragraphs($nb = 3) + public static function paragraphs($nb = 3, $asText = false) { $paragraphs = array(); for ($i=0; $i < $nb; $i++) { $paragraphs []= static::paragraph(); } - return $paragraphs; + return $asText ? join("\n\n", $paragraphs) : $paragraphs; } /**