Code Duplication    Length = 30-31 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 905-935 (lines=31) @@
902
     * @return false|int
903
     *                   <p>false on error</p>
904
     */
905
    public function delete(
906
        string $table,
907
        $where,
908
        string $databaseName = null
909
    ) {
910
        // init
911
        $table = \trim($table);
912
913
        if ($table === '') {
914
            $this->debug->displayError('Invalid table name, table name in empty.', false);
915
916
            return false;
917
        }
918
919
        if (\is_string($where)) {
920
            $WHERE = $this->escape($where, false);
921
        } elseif (\is_array($where)) {
922
            $WHERE = $this->_parseArrayPair($where, 'AND');
923
        } else {
924
            $WHERE = '';
925
        }
926
927
        if ($databaseName) {
928
            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
929
        }
930
931
        $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
932
933
        $return = $this->query($sql);
934
935
        \assert(\is_int($return) || $return === false);
936
937
        return $return;
938
    }
@@ 2363-2392 (lines=30) @@
2360
     * @return false|Result
2361
     *                      <p>false on error</p>
2362
     */
2363
    public function select(
2364
        string $table,
2365
        $where = '1=1',
2366
        string $databaseName = null
2367
    ) {
2368
        // init
2369
        $table = \trim($table);
2370
2371
        if ($table === '') {
2372
            $this->debug->displayError('Invalid table name, table name in empty.', false);
2373
2374
            return false;
2375
        }
2376
2377
        if (\is_string($where)) {
2378
            $WHERE = $this->escape($where, false);
2379
        } elseif (\is_array($where)) {
2380
            $WHERE = $this->_parseArrayPair($where, 'AND');
2381
        } else {
2382
            $WHERE = '';
2383
        }
2384
2385
        if ($databaseName) {
2386
            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2387
        }
2388
2389
        $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
2390
2391
        $return = $this->query($sql);
2392
        \assert($return instanceof Result || $return === false);
2393
2394
        return $return;
2395
    }