Code Duplication    Length = 30-31 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 915-945 (lines=31) @@
912
     * @return false|int
913
     *                   <p>false on error</p>
914
     */
915
    public function delete(
916
        string $table,
917
        $where,
918
        string $databaseName = null
919
    ) {
920
        // init
921
        $table = \trim($table);
922
923
        if ($table === '') {
924
            $this->debug->displayError('Invalid table name, table name in empty.', false);
925
926
            return false;
927
        }
928
929
        if (\is_string($where)) {
930
            $WHERE = $this->escape($where, false);
931
        } elseif (\is_array($where)) {
932
            $WHERE = $this->_parseArrayPair($where, 'AND');
933
        } else {
934
            $WHERE = '';
935
        }
936
937
        if ($databaseName) {
938
            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
939
        }
940
941
        $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
942
943
        $return = $this->query($sql);
944
945
        \assert(\is_int($return) || $return === false);
946
947
        return $return;
948
    }
@@ 2316-2345 (lines=30) @@
2313
     * @return false|Result
2314
     *                      <p>false on error</p>
2315
     */
2316
    public function select(
2317
        string $table,
2318
        $where = '1=1',
2319
        string $databaseName = null
2320
    ) {
2321
        // init
2322
        $table = \trim($table);
2323
2324
        if ($table === '') {
2325
            $this->debug->displayError('Invalid table name, table name in empty.', false);
2326
2327
            return false;
2328
        }
2329
2330
        if (\is_string($where)) {
2331
            $WHERE = $this->escape($where, false);
2332
        } elseif (\is_array($where)) {
2333
            $WHERE = $this->_parseArrayPair($where, 'AND');
2334
        } else {
2335
            $WHERE = '';
2336
        }
2337
2338
        if ($databaseName) {
2339
            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2340
        }
2341
2342
        $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
2343
2344
        $return = $this->query($sql);
2345
        \assert($return instanceof Result || $return === false);
2346
2347
        return $return;
2348
    }