diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-07-16 17:37:50 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-07-16 17:39:16 +0300 |
commit | 88354144785a2a36fa3afebe336e2c2635efedfc (patch) | |
tree | 011d65bbf43ffc6022099602390180a9d64bb64d /src | |
parent | 9e3a9ee729eaada8585fa8f33ba7d8ac2231495a (diff) | |
download | sql-parser-88354144785a2a36fa3afebe336e2c2635efedfc.zip sql-parser-88354144785a2a36fa3afebe336e2c2635efedfc.tar.gz sql-parser-88354144785a2a36fa3afebe336e2c2635efedfc.tar.bz2 |
Refactoring.
Diffstat (limited to 'src')
-rw-r--r-- | src/Lexer.php | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/Lexer.php b/src/Lexer.php index 6e8c0fd..0bdd2f5 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -159,24 +159,21 @@ class Lexer */ public function __construct($str, $strict = false) { + // `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)) { - $len = strlen($str); if ((USE_UTF_STRINGS) && ($len != mb_strlen($str))) { $str = new UtfString($str); } } - if ($str instanceof UtfString) { - $this->str = $str; - $this->len = $str->length(); - } else { - $this->str = $str; - // `strlen` is used instead of `mb_strlen` because the lexer - // needs to parse each byte of the input. - $this->len = $len; - } + $this->str = $str; + $this->len = ($str instanceof UtfString) ? $str->length() : $len; + $this->strict = $strict; // Setting the delimiter. |