class TextIterator implements Iterator (View source)

A UTF8-aware TextIterator

Constants

CODE_POINT

COMB_SEQUENCE

CHARACTER

WORD

LINE

SENTENCE

DONE

WORD_NONE

WORD_NONE_LIMIT

WORD_NUMBER

WORD_NUMBER_LIMIT

WORD_LETTER

WORD_LETTER_LIMIT

WORD_KANA

WORD_KANA_LIMIT

LINE_SOFT

LINE_SOFT_LIMIT

LINE_HARD

LINE_HARD_LIMIT

SENTENCE_TERM

SENTENCE_TERM_LIMIT

SENTENCE_SEP

SENTENCE_SEP_LIMIT

REGEXP_SENTENCE_DELIMITERS

Properties

protected int $iteratorType
protected string $subject
protected int $currentPosition
protected ArrayObject $iteratorCache
protected ArrayIterator $iteratorCacheIterator
protected TextIteratorElement $previousElement

Methods

__construct(string $subject, int $iteratorType = self::CHARACTER)

Constructs the TextIterator

string
current()

Returns the current element

void
next()

Advances the iterator to the next element

mixed
key()

Returns the key of the current element. That means the number of the current element starting with 0.

bool
valid()

Returns true, if the current element is not the end of the iterator

void
rewind()

Sets the iterator back to the first element

int
offset()

Returns the offset in the original given string of the current element

string
previous()

Returns the previous element

string
last()

Returns the last element of the iterator

string
following(int $offset)

Returns the next elment following the character of the original string given by its offset

string
preceding(int $offset)

Returns the element preceding the character of the original string given by its offset

bool
isBoundary()

Returns true if the current element is a boundary element.

array
getAll()

Returns all elements of the iterator in an array

getRuleStatus()

No description

getRuleStatusArray()

No description

getAvailableLocales()

No description

string
first()

Returns the first element

Details

__construct(string $subject, int $iteratorType = self::CHARACTER)

Constructs the TextIterator

Parameters

string $subject
int $iteratorType

The type of iterator

Exceptions

Exception

string current()

Returns the current element

Return Value

string

The value of the current element

void next()

Advances the iterator to the next element

Return Value

void

mixed key()

Returns the key of the current element. That means the number of the current element starting with 0.

Return Value

mixed

Key (number) of the current element

bool valid()

Returns true, if the current element is not the end of the iterator

Return Value

bool

True if the iterator has not reached it's end

void rewind()

Sets the iterator back to the first element

Return Value

void

int offset()

Returns the offset in the original given string of the current element

Return Value

int

The offset of the current element

string previous()

Returns the previous element

Return Value

string

The previous element of the iterator

string last()

Returns the last element of the iterator

Return Value

string

the last element of the iterator

string following(int $offset)

Returns the next elment following the character of the original string given by its offset

Parameters

int $offset

The offset of the character

Return Value

string

The element following this character

string preceding(int $offset)

Returns the element preceding the character of the original string given by its offset

Parameters

int $offset

The offset of the character

Return Value

string

The element preceding this character

bool isBoundary()

Returns true if the current element is a boundary element.

Boundaries are: CHARACTER: none WORD: .,!?; SENTENCE: .,!?; LINE: <\n>

Return Value

bool

True if the current element is a boundary element

array getAll()

Returns all elements of the iterator in an array

Return Value

array

All elements of the iterator

getRuleStatus()

No description

getRuleStatusArray()

No description

getAvailableLocales()

No description

string first()

Returns the first element

Return Value

string

The first element of the iterator