Sledgehammer Framework

Text extends Base
in package
implements ArrayAccess

Text, a string class for handeling (multibyte) strings with OOP syntax Modelled after the C# String class.

Tags
link
http://msdn.microsoft.com/en-us/library/system.string.aspx

Interfaces, Classes, Traits and Enums

ArrayAccess

Table of Contents

$length  : int
$text  : string
The string in UTF-8.
__call()  : mixed
Report that the $method doesn't exist.
__callStatic()  : mixed
Report that the $method doesn't exist.
__construct()  : mixed
Construct the Text object and convert $text to UTF-8.
__get()  : mixed
Virtual properties like "length".
__set()  : mixed
Report that $property doesn't exist and set the property to the given $value.
__toString()  : string
Allow Text objects to be used as php strings.
capitalize()  : Text
Convert the first character to uppercase and the rest to lowercase.
endsWith()  : bool
Determines whether the end of this text matches the specified $text.
equals()  : bool
Check if this text has same value as $text.
indexOf()  : int|false
Returns the index of the first occurrence of the specified $text.
offsetExists()  : bool
Whether a offset exists.
offsetGet()  : mixed
Offset to retrieve.
offsetSet()  : mixed
Offset to set.
offsetUnset()  : mixed
Offset to unset.
replace()  : Text
Returns a copy of this text in which all occurrences of $search are replaced with $replace.
reverse()  : Text
Returns a copy of this text written backwards.
split()  : array<string|int, mixed>
Split a string by the $separator Similar to explode().
startsWith()  : bool
Determines whether the beginning of this text matches the specified $text.
substring()  : Text
Returns a substring from this text.
toLower()  : Text
Returns a copy of this text converted to lowercase.
toUpper()  : Text
Returns a copy of this text converted to uppercase.
trim()  : Text
Removes all leading and trailing white-space characters from the current text.
trimEnd()  : Text
Removes all trailing occurrences white-space characters from the current text.
trimStart()  : Text
Removes all leading white-space characters from the current text.
truncate()  : Text
Returns a truncated copy of this text.
ucfirst()  : Text
Convert the first character to uppercase.

Properties

$length read-only

public int $length

The number of characters

$text

The string in UTF-8.

private string $text

Methods

__call()

Report that the $method doesn't exist.

public __call(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
$method : string
$arguments : array<string|int, mixed>
Return values
mixed

__callStatic()

Report that the $method doesn't exist.

public static __callStatic(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
$method : string
$arguments : array<string|int, mixed>
Return values
mixed

__construct()

Construct the Text object and convert $text to UTF-8.

public __construct(string $text[, string|array<string|int, mixed> $charset = null ]) : mixed
Parameters
$text : string

The text

$charset : string|array<string|int, mixed> = null

string: The charset of $text; array: Autodetect encoding, example: array('ASCII', 'UTF-8', 'ISO-8859-15'); null: defaults to Framework::$charset

Return values
mixed

__get()

Virtual properties like "length".

public __get(string $property) : mixed
Parameters
$property : string
Return values
mixed

__set()

Report that $property doesn't exist and set the property to the given $value.

public __set(string $property, mixed $value) : mixed
Parameters
$property : string
$value : mixed
Return values
mixed

__toString()

Allow Text objects to be used as php strings.

public __toString() : string
Return values
string

capitalize()

Convert the first character to uppercase and the rest to lowercase.

public capitalize() : Text
Return values
Text

endsWith()

Determines whether the end of this text matches the specified $text.

public endsWith(string $text) : bool
Parameters
$text : string
Return values
bool

equals()

Check if this text has same value as $text.

public equals(Text $text[, bool $ignoreCase = false ]) : bool
Parameters
$text : Text
$ignoreCase : bool = false
Return values
bool

indexOf()

Returns the index of the first occurrence of the specified $text.

public indexOf(string $text, int $offset[, bool $ignoreCase = false ]) : int|false
Parameters
$text : string

Needle/Search

$offset : int

Skip the first X characters

$ignoreCase : bool = false

Use true for a case-insensitive search.

Tags
link
http://nl.php.net/manual/en/function.strpos.php
Return values
int|false

replace()

Returns a copy of this text in which all occurrences of $search are replaced with $replace.

public replace(string $search, string $replace) : Text
Parameters
$search : string
$replace : string
Return values
Text

reverse()

Returns a copy of this text written backwards.

public reverse() : Text
Return values
Text

split()

Split a string by the $separator Similar to explode().

public split(string $separator[, int|null $limit = null ]) : array<string|int, mixed>
Parameters
$separator : string
$limit : int|null = null

(optional)

Return values
array<string|int, mixed>

startsWith()

Determines whether the beginning of this text matches the specified $text.

public startsWith(string $text) : bool
Parameters
$text : string
Return values
bool

substring()

Returns a substring from this text.

public substring(int $offset[, int $length = null ]) : Text

Similar to substr().

Parameters
$offset : int
$length : int = null

(optional)

Return values
Text

toLower()

Returns a copy of this text converted to lowercase.

public toLower() : Text
Return values
Text

toUpper()

Returns a copy of this text converted to uppercase.

public toUpper() : Text
Return values
Text

trim()

Removes all leading and trailing white-space characters from the current text.

public trim([ $charlist = null ]) : Text
Parameters
$charlist : = null

(optional) The stripped characters can also be specified. list the characters that you want to be stripped.

Tags
link
http://php.net/manual/en/function.trim.php
Return values
Text

trimEnd()

Removes all trailing occurrences white-space characters from the current text.

public trimEnd([array<string|int, mixed> $charlist = null ]) : Text
Parameters
$charlist : array<string|int, mixed> = null

(optional) The stripped characters can also be specified. list the characters that you want to be stripped.

Tags
link
http://php.net/manual/en/function.rtrim.php
Return values
Text

trimStart()

Removes all leading white-space characters from the current text.

public trimStart([array<string|int, mixed> $charlist = null ]) : Text
Parameters
$charlist : array<string|int, mixed> = null

(optional) The stripped characters can also be specified. list the characters that you want to be stripped.

Tags
link
http://php.net/manual/en/function.ltrim.php
Return values
Text

truncate()

Returns a truncated copy of this text.

public truncate(int $maxLenght[, string $suffix = null ]) : Text

Only appends the given suffix when the text was trucated.

Parameters
$maxLenght : int
$suffix : string = null

[optional] Defaults to the "..." character

Return values
Text

ucfirst()

Convert the first character to uppercase.

public ucfirst() : Text
Return values
Text

Search results