Code Duplication    Length = 8-14 lines in 2 locations

src/Connections/DatabaseTransactionsTrait.php 2 locations

@@ 30-43 (lines=14) @@
27
        $count = count($record);
28
29
        $sql = "INSERT INTO {$table} (";
30
        foreach ($record as $key => $value) {
31
            
32
            $count--;
33
34
            if ($key === $this->getPrimaryKey($table)) {
35
                continue;
36
            }
37
38
            if ($count > 0) {
39
                $sql = $sql."{$key}, ";
40
            } else {
41
                $sql = $sql."{$key}) ";
42
            }
43
        }
44
45
        $count = count($record);
46
@@ 144-151 (lines=8) @@
141
        $count = count($record);
142
143
        $sql = "UPDATE {$table} SET ";
144
        foreach ($record as $key => $value) {
145
            if ($count > 1) {
146
                $sql = $sql."{$key}={$value}, ";
147
            } else {
148
                $sql = $sql."{$key}={$value} ";
149
            }
150
            $count--;
151
        }
152
        $sql .= "WHERE {$this->getPrimaryKey($table)}='{$pk}'";
153
154
        return $this->getPdo()->prepare($sql)->execute();