Code Duplication    Length = 6-7 lines in 2 locations

src/Model.php 2 locations

@@ 153-158 (lines=6) @@
150
       
151
        $bindNameParameters = [];
152
        $sqlUpdate = "UPDATE " . $this->getTableName() . " SET " ;
153
        foreach ($this->properties as $columnName => $columnValue) {
154
            if($columnName == 'id') continue;
155
            $bindColumnName = ':' . $columnName;
156
            $sqlUpdate .= "$columnName = $bindColumnName,";
157
            $bindNameParameters[$bindColumnName] = $columnValue;
158
        }
159
        //Remove the last comma in sql command then join it to the other query part.
160
        $sqlUpdate = substr($sqlUpdate, 0, -1)." WHERE id = :id";
161
        $sqlStatement = $this->databaseConnection->prepare($sqlUpdate);
@@ 179-185 (lines=7) @@
176
        $columnValues = "";
177
        $bindNameParameters = [];
178
        $sqlCreate = "INSERT" . " INTO " . $this->getTableName()." (";
179
        foreach ($this->properties as $columnName => $columnValue) {
180
181
            $bindColumnName = ':' . $columnName;
182
            $columnNames .= $columnName.",";
183
            $columnValues .= $bindColumnName.",";
184
            $bindNameParameters[$bindColumnName] = $columnValue;
185
        }
186
        // Remove ending comma and whitespace.
187
        $columnNames = substr($columnNames, 0, -1);
188
        $columnValues = substr($columnValues, 0, -1);