Skip to content

Commit 5b6bc62

Browse files
committed
clean up
1 parent 03cffb0 commit 5b6bc62

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/SQLSplitter.php

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private static function getStatements(string $query, string $dbType, string $del
9999
$stringChar = null;
100100
$isInTag = false;
101101
$tagChar = null;
102-
$resultQueries = [];
102+
103103
for ($index = 0; $index < count($charArray); $index++) {
104104
$char = $charArray[$index];
105105
$previousChar = $index > 0 ? $charArray[$index - 1] : null;
@@ -134,8 +134,7 @@ private static function getStatements(string $query, string $dbType, string $del
134134
// it's delimiter
135135
list($delimiterSymbol, $delimiterEndIndex) = $delimiterResult;
136136
$query = substr($query, $delimiterEndIndex);
137-
$resultQueries = self::getStatements($query, $dbType, $delimiterSymbol);
138-
break;
137+
return self::getStatements($query, $dbType, $delimiterSymbol);
139138
}
140139
}
141140
if ($char == "$" && $isInComment == false && $isInString == false) {
@@ -169,19 +168,15 @@ private static function getStatements(string $query, string $dbType, string $del
169168
}
170169
$splittingIndex = $index;
171170
// if (delimiter == ";") { $splittingIndex = index + 1 }
172-
$resultQueries = self::getQueryParts($query, $splittingIndex, $delimiter);
173-
break;
171+
return self::getQueryParts($query, $splittingIndex, $delimiter);
174172
}
175173
}
176-
if (count($resultQueries) == 0) {
177-
if ($query != null) {
178-
$query = trim($query);
179-
}
180-
$resultQueries[] = $query;
181-
$resultQueries[] = null;
174+
175+
if ($query != null) {
176+
$query = trim($query);
182177
}
183178

184-
return $resultQueries;
179+
return [$query, null];
185180
}
186181

187182
/**
@@ -195,14 +190,10 @@ private static function getQueryParts(string $query, int $splittingIndex, string
195190
{
196191
$statement = substr($query, 0, $splittingIndex);
197192
$restOfQuery = substr($query, $splittingIndex + strlen($delimiter));
198-
$result = [];
199193
if ($statement != null) {
200194
$statement = trim($statement);
201195
}
202-
$result[] = $statement;
203-
$result[] = $restOfQuery;
204-
205-
return $result;
196+
return [$statement, $restOfQuery];
206197
}
207198

208199
/**

0 commit comments

Comments
 (0)