public function __construct($str, $strict = false, $delimiter = null)
{
// `strlen` is used instead of `mb_strlen` because the lexer needs to
// parse each byte of the input.
$len = $str instanceof UtfString ? $str->length() : strlen($str);
// For multi-byte strings, a new instance of `UtfString` is
// initialized (only if `UtfString` usage is forced.
if (!$str instanceof UtfString) {
if (USE_UTF_STRINGS && $len !== mb_strlen($str, 'UTF-8')) {
$str = new UtfString($str);
}
}
$this->str = $str;
$this->len = $str instanceof UtfString ? $str->length() : $len;
$this->strict = $strict;
// Setting the delimiter.
$this->setDelimiter(!empty($delimiter) ? $delimiter : static::$DEFAULT_DELIMITER);
$this->lex();
}