summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDan Ungureanu <udan1107@gmail.com>2015-07-16 17:37:50 +0300
committerDan Ungureanu <udan1107@gmail.com>2015-07-16 17:39:16 +0300
commit88354144785a2a36fa3afebe336e2c2635efedfc (patch)
tree011d65bbf43ffc6022099602390180a9d64bb64d /src
parent9e3a9ee729eaada8585fa8f33ba7d8ac2231495a (diff)
downloadsql-parser-88354144785a2a36fa3afebe336e2c2635efedfc.zip
sql-parser-88354144785a2a36fa3afebe336e2c2635efedfc.tar.gz
sql-parser-88354144785a2a36fa3afebe336e2c2635efedfc.tar.bz2
Refactoring.
Diffstat (limited to 'src')
-rw-r--r--src/Lexer.php17
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.