Code Duplication    Length = 7-10 lines in 6 locations

src/Dialect/AbstractDialect.php 4 locations

@@ 119-125 (lines=7) @@
116
     */
117
    public function getCopyTable(TableNodeInterface $from, TableNodeInterface $to)
118
    {
119
        if ($from->getColumns()) {
120
            $fromColumns = implode(',', array_map(function ($column) {
121
                return $this->format('{column|q}', ['column' => $column]);
122
            }, $from->getColumns()));
123
        } else {
124
            $fromColumns = '*';
125
        }
126
127
        if ($to->getColumns()) {
128
            $toColumns = sprintf(
@@ 127-136 (lines=10) @@
124
            $fromColumns = '*';
125
        }
126
127
        if ($to->getColumns()) {
128
            $toColumns = sprintf(
129
                ' (%s)',
130
                implode(',', array_map(function ($column) {
131
                    return $this->format('{column|q}', ['column' => $column]);
132
                }, $to->getColumns()))
133
            );
134
        } else {
135
            $toColumns = '';
136
        }
137
138
        return [
139
            $this->format(
@@ 160-166 (lines=7) @@
157
     */
158
    public function getSelectSyntax(TableNodeInterface $table)
159
    {
160
        if ($table->getColumns()) {
161
            $fromColumns = implode(',', array_map(function ($column) {
162
                return $this->format('{column|q}', ['column' => $column]);
163
            }, $table->getColumns()));
164
        } else {
165
            $fromColumns = '*';
166
        }
167
168
        $where = '';
169
        if ($table instanceof SourceTableNodeInterface && $table->getWhere()) {
@@ 194-203 (lines=10) @@
191
     */
192
    public function getInsertSyntax(TableNodeInterface $table, array $rows)
193
    {
194
        if ($table->getColumns()) {
195
            $toColumns = sprintf(
196
                ' (%s)',
197
                implode(',', array_map(function ($column) {
198
                    return $this->format('{column|q}', ['column' => $column]);
199
                }, $table->getColumns()))
200
            );
201
        } else {
202
            $toColumns = '';
203
        }
204
205
        $bind = [];
206
        $insert = [];

src/Dialect/RedshiftDialect.php 2 locations

@@ 453-459 (lines=7) @@
450
        $credentials = $this->getS3CredentialsFromFile($file);
451
        $bucket = $this->getS3BucketFromFile($file);
452
453
        if ($table->getColumns()) {
454
            $columns = implode(',', array_map(function ($column) {
455
                return $this->format('{column|q}', ['column' => $column]);
456
            }, $table->getColumns()));
457
        } else {
458
            $columns = '';
459
        }
460
461
        $bind = [
462
            sprintf('s3://%s/%s', $bucket, $file->getPath()),
@@ 549-555 (lines=7) @@
546
        $credentials = $this->getS3CredentialsFromFile($file);
547
        $bucket = $this->getS3BucketFromFile($file);
548
549
        if ($table->getColumns()) {
550
            $columns = implode(',', array_map(function ($column) {
551
                return $this->format('{column|q}', ['column' => $column]);
552
            }, $table->getColumns()));
553
        } else {
554
            $columns = '';
555
        }
556
557
        $bind = [
558
            sprintf('s3://%s/%s', $bucket, $file->getPath()),