/ LJCPHPCodeDoc / LJCTextBuilderLib / LJCTextBuilder


Syntax

PHP
class LJCTextBuilder

Represents a built string value

Remarks

The LJCTextBuilder class is designed for creating text. It can also be used to create HTML and XML text.

The LJCTextBuilder class stores the built text internally. The text is retrieved with the ToString() method.

Add Text Methods
AddLine(), AddText()
These "Add Text" methods add text to the builder unmodified except for AddLine() which appends a newline.

Append Text Methods
Line(), Text()
"Append Text" methods add the potentially indented and wrapped text to the builder.
The Text() method appends the supplied text without an ending newline. This behavior is done for consistency and it allows for appending to the existing if desired text.
The "Append Text" methods start the text with a newline if the builder already has text, param allowNewLine = true (default) and the builder text does not already end with a newline.
Use the "addIndent" parameter set to "false" when appending text to the builder that was retrieved using a "Get Text" method. This is because the indent may already have been added to the text by the "Get Text" method.

The AddIndent() method manually controls the current indent count. The indent string length is calculated with the properties (IndentCount * IndentCharCount) and can be retrieved with the IndentLength property.

Get Text Methods
GetLine(), GetText()
The "Get Text" methods create and return the potentialy indented and wrapped text but do not add it to the builder.
This allows for using the text outside of the builder.
The GetLine() and GetText() methods modify the returned text the same as the Line() and Text() methods.
Use the "addIndent" parameter set to "false" when appending text to the builder that was retrieved using a "Get Text" method. This is because the indent may already have been added to the text by the "Get Text" method.

Append Element Methods
Begin(), Create(), End()
These methods append element tags and content. Begin() automatically increments the IndentCount by 1. Create() also increments the IndentCount by 1 if the isEmpty parameter is false and the close parameter is false. End() automatically decrements the IndentCount by 1 if the IndentCount is currently greater than zero.
The "Append Element" methods append the supplied text without an ending newline. This behavior is done for consistency and it allows for appending to the existing text if desired.
The "Append Element" methods start the appended text with a newline if the builder already has text, param allowNewLine = true and builder text does not already end with a newline.

Get Element Methods
GetBegin(), GetCreate(), GetEnd()
The "Get Element" methods create and return the potentialy indented and wrapped text but do not add it to the builder.
This allows for using the text outside of the builder.
Use the "addIndent" parameter set to "false" when appending text to the builder that was retrieved using a "Get Text" method. This is because the indent may already have been added to the text by the "Get Text" method.

Public Functions
Constructor Methods
construct Initializes a class instance.
Data Class Methods
ToString Gets the built string.
Add Text
AddLine Appends a text line without modification.
AddText Appends text without modification.
Append Text
Line Appends a potentially indented text line to the builder.
Text Appends the potentially indented text.
Get Text
GetLine Gets the potentially indented and wrapped text line.
GetText Gets the potentially indented and wrapped text.
Other Get Text
GetIndented Gets a new potentially indented line.
GetIndentString Returns the current indent string.
GetWrapped Appends added text and new wrapped line.
Get Attribs
Attribs Gets common element attributes.
GetAttribs Gets the attributes text.
StartAttribs Creates the HTML element attributes.
StartXMLAttribs Creates the XML element attributes.
TableAttribs Gets common table attributes.
Append Element
Begin Appends the element begin tag.
Create Appends an element.
End Appends the element end tag.
Get Element
GetBegin Gets the element begin tag.
GetCreate Gets an element.
GetEnd Gets the element end tag.
Other Methods
AddChildIndent Adds the new (child) indents.
AddIndent Changes the IndentCount by the provided value.
EndsWithNewLine Indicates if the builder text ends with a newline.
GetTextState Gets a current LJCTextState object.
HasText Indicates if the builder has text.
IndentLength Gets the current indent length.
StartWithNewLine Checks if the text can start with a newline.
getIndentCount _FunctionSummary_
30 Functions

Public Properties
$ClassName The class name for debugging.
$LogText The debug text.
$IndentCharCount _PropertySummary_
$LineLength Gets the current length.
$LineLimit Gets or sets the character limit.
$WrapEnabled Indicates if the wrap functionality is enabled.

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.