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
    }
@@ 2318-2347 (lines=30) @@
2315
     * @return false|Result
2316
     *                      <p>false on error</p>
2317
     */
2318
    public function select(
2319
        string $table,
2320
        $where = '1=1',
2321
        string $databaseName = null
2322
    ) {
2323
        // init
2324
        $table = \trim($table);
2325
2326
        if ($table === '') {
2327
            $this->debug->displayError('Invalid table name, table name in empty.', false);
2328
2329
            return false;
2330
        }
2331
2332
        if (\is_string($where)) {
2333
            $WHERE = $this->escape($where, false);
2334
        } elseif (\is_array($where)) {
2335
            $WHERE = $this->_parseArrayPair($where, 'AND');
2336
        } else {
2337
            $WHERE = '';
2338
        }
2339
2340
        if ($databaseName) {
2341
            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2342
        }
2343
2344
        $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
2345
2346
        $return = $this->query($sql);
2347
        \assert($return instanceof Result || $return === false);
2348
2349
        return $return;
2350
    }