Generates Lorem Ipsum text

author etessore
version 1.0.0
package classes

 Methods

Magic method called when the current object is casted to string

__toString() 

Initializes the current object with default settings

defaults() : \LipsumGenerator

Returns

\LipsumGenerator$this for chainability

Removes current config from WP options system

flush() : \LipsumGenerator

Returns

\LipsumGenerator$this for chainability

Hooks to 'the_content' hook.

hook() : \LipsumGenerator

If the page has no content it will fill it with the generated text.

Returns

\LipsumGenerator$this for chainability

Look for a config stored in the db If it doesn't exist it will load the default one

init() : \LipsumGenerator

Returns

\LipsumGenerator$this for chainability

Retrives config from WP options system

load() : boolean

Returns

booleanfalse if config is not present

Renders the current object according to the current format

render() : \LipsumGenerator

Returns

\LipsumGenerator$this for chainability

Store config into WP options system

save() : \LipsumGenerator

Returns

\LipsumGenerator$this for chainability

Sets the first n words of the generated text.

set_begins_with(array $beginning) : \LipsumGenerator

Usually they are 'Lorem ipsum'.

Parameters

$beginning

array

list of first n words

Returns

\LipsumGenerator$this for chainability

Sets the dictionary for the current generator

set_dictionary(\GeneratorDictionary $dictionary) : \LipsumGenerator

Parameters

$dictionary

\GeneratorDictionary

the dictionary

Returns

\LipsumGenerator$this for chainability

Set the format for the current object use only self::FORMAT_* constants

set_format(int $format) : \LipsumGenerator
see \self::FORMAT_RICH_HTML
see \self::FORMAT_HTML
see \self::FORMAT_TEXT
see \self::FORMAT_PLAIN

Parameters

$format

int

the format

Returns

\LipsumGenerator$this for chainability

Sets the mathematical object used for count words and punctuage distribution

set_math(\GaussianMath $math) 

Parameters

Sets the minimum amount of words until a single word can be repeated

set_min_repeat_count($min_repeat_count) : \LipsumGenerator

Parameters

$min_repeat_count

the number of words withour repetitions

Returns

\LipsumGenerator$this for chainability

Sets the number of paragraphs for the current object

set_number_of_paragraphs(int $number_of_paragraphs) : \LipsumGenerator

Parameters

$number_of_paragraphs

int

the number

Returns

\LipsumGenerator$this for chainability

Sets the configuration for the rich html generation

set_rich_html_config(array $config) 

Parameters

$config

array

an array of parameters: $default = array( 'strong' => array( 'percent' => 2, 'max_words' => 5, 'params' => '' ), 'a' => array( 'percent' => 5, 'max_words' => 5, 'params' => 'href="#"' ), 'em' => array( 'percent' => 10, 'max_words' => 5, 'params' => '' ) );

Sets how many words a paragraph is made by.

set_words_per_paragraph(int $words_per_paragraph) 

Parameters

$words_per_paragraph

int

the number of words

Sets how many words a sentence is made by

set_words_per_sentence(int $words_per_sentence) : \LipsumGenerator

Parameters

$words_per_sentence

int

number of words

Returns

\LipsumGenerator$this for chainability

Hook for the_content: if there is no content it appends the generated

the_content($content) 

Parameters

$content

string the content

Forces the given sentences (paragraph) to start with $this->beginning list of words.

force_beginning(array $sentences) 

Parameters

$sentences

array

the list of sentences

Returns a number on a gaussian distribution based on the average word length of an english sentence.

gaussian_sentence() 

Statistics Source: http://hearle.nahoo.net/Academic/Maths/Sentence.html Average: 24.46 Standard Deviation: 5.08

Retrieves the config set for this generator

get_config() : array

Returns

arraythe list of settings

Builds a single paragraph

get_paragraph() 

Retrieves an array of random words

get_words($count) : array

Parameters

$count

int the number of words to ber retrieved

Returns

arraya list of random words

Determines the number of commas for a sentence of the given length.

numberOfCommas($len) 

Average and standard deviation are determined superficially

Parameters

$len

int a medium amount of words between two commas

Inserts commas and periods in the given array of words.

punctuate(array $sentence) 

Parameters

$sentence

array

the list of sentence

Generates and renders in html format

render_html() : \LipsumGenerator
see \LipsumGenerator::FORMAT_HTML

Returns

\LipsumGenerator$this for chainability

Generates and renders in plain forma

render_plain() : \LipsumGenerator
see \LipsumGenerator::FORMAT_PLAIN

Returns

\LipsumGenerator$this for chainability

Generates and renders in rich html format

render_rich_html() : \LipsumGenerator
see \LipsumGenerator::FORMAT_RICH_HTML

Returns

\LipsumGenerator$this for chainability

Generates and render in text format

render_text() : \LipsumGenerator
see \LipsumGenerator::FORMAT_TEXT

Returns

\LipsumGenerator$this for chainability

Bulk configure the generator.

set_config(array $config) : \LipsumGenerator

Parameters

$config

array

the list of settings pairs name=>value

Returns

\LipsumGenerator$this for chainability

 Properties

 

all generated texts will start with thouse words (ex. 'Lorem Ipsum')

$beginning : array
 

a dictionary for the current generator

$dictionary : \GeneratorDictionary
 

the format type

$format : string
 

some math utils

$gaussian_math : \GaussianMath
 

the minimum amount of words until a single word can be repeated

$min_repeat_count : int
 

number of paragraphs

$number_of_paragraphs : int
 

the rendered text

$render : string
 

config for rich html generator

$rich_html_config : array
 

a seed for random generator

$seed : mixed
 

words in a paragraph

$words_per_paragraph : int
 

minimum amount of words until a single word can be repeated

$words_per_sentence : int

 Constants

 

FORMAT_HTML

FORMAT_HTML 
const int use html tag

to separate paragraphs

 

FORMAT_PLAIN

FORMAT_PLAIN 
const int generates plain text with a newline as separation between paragraphs
 

FORMAT_RICH_HTML

FORMAT_RICH_HTML 
const int generates html with and

tags

 

FORMAT_TEXT

FORMAT_TEXT 
const int use 2 newlines to separate paragraphs and a tab before the first word of every paragraph
 

OPTION_NAME

OPTION_NAME 
const string the WP option name where the generator can store his config