Bounds and reference fixes

This commit is contained in:
Dennis Eichhorn 2016-02-06 18:19:42 +01:00
parent c2d3672803
commit d44f18963d

View File

@ -35,7 +35,7 @@ class Text
* @var string[] * @var string[]
* @since 1.0.0 * @since 1.0.0
*/ */
public static $words_west = ['lorem', private static $words_west = ['lorem',
'ipsum', 'ipsum',
'dolor', 'dolor',
'sit', 'sit',
@ -294,11 +294,15 @@ class Text
*/ */
public function generateText($length, $words = null) public function generateText($length, $words = null)
{ {
if($length === 0) {
return '';
}
if ($words === null) { if ($words === null) {
$words = self::$words_west; $words = self::$words_west;
} }
$punctuation = self::generatePunctuation($length); $punctuation = $this->generatePunctuation($length);
$punctuation_count = array_count_values( $punctuation_count = array_count_values(
array_map( array_map(
function ($item) { function ($item) {
@ -311,11 +315,11 @@ class Text
$this->sentences = $punctuation_count['.'] + $punctuation_count['!'] + $punctuation_count['?']; $this->sentences = $punctuation_count['.'] + $punctuation_count['!'] + $punctuation_count['?'];
if ($this->hasParagraphs) { if ($this->hasParagraphs) {
$paragraph = self::generateParagraph($this->sentences); $paragraph = $this->generateParagraph($this->sentences);
} }
if ($this->hasFormatting) { if ($this->hasFormatting) {
$formatting = self::generateFormatting($length); $formatting = $this->generateFormatting($length);
} }
$sentenceCount = 0; $sentenceCount = 0;