Skip to content

Commit 9ee2101

Browse files
committed
fix: no new line when using begin data
1 parent 90e42b2 commit 9ee2101

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/ControlFileBuilder.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,20 @@ public function build(): string
2424
{
2525
$template = File::get($this->getStub());
2626

27-
return Str::of($template)
27+
$sql = Str::of($template)
2828
->replace('$OPTIONS', $this->options())
2929
->replace('$FILES', $this->inputFiles())
3030
->replace('$METHOD', $this->method())
3131
->replace('$INSERTS', $this->inserts())
32-
->replace('$BEGINDATA', $this->beginData())
32+
->replace("\$BEGINDATA\n", $this->beginData())
3333
->toString();
34+
35+
if ($this->loader->beginData) {
36+
// remove last new line from the $sql when beginData is set.
37+
$sql = substr($sql, 0, -1);
38+
}
39+
40+
return $sql;
3441
}
3542

3643
protected function getStub(): string
@@ -68,7 +75,7 @@ protected function beginData(): string
6875
$sql = '';
6976
if ($this->loader->beginData) {
7077
$sql .= 'BEGINDATA'.PHP_EOL;
71-
$sql .= $this->arrayToCsv($this->loader->beginData).PHP_EOL;
78+
$sql .= $this->arrayToCsv($this->loader->beginData);
7279
}
7380

7481
return $sql;

0 commit comments

Comments
 (0)