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
    }
@@ 2382-2411 (lines=30) @@
2379
     * @return false|Result
2380
     *                      <p>false on error</p>
2381
     */
2382
    public function select(
2383
        string $table,
2384
        $where = '1=1',
2385
        string $databaseName = null
2386
    ) {
2387
        // init
2388
        $table = \trim($table);
2389
2390
        if ($table === '') {
2391
            $this->debug->displayError('Invalid table name, table name in empty.', false);
2392
2393
            return false;
2394
        }
2395
2396
        if (\is_string($where)) {
2397
            $WHERE = $this->escape($where, false);
2398
        } elseif (\is_array($where)) {
2399
            $WHERE = $this->_parseArrayPair($where, 'AND');
2400
        } else {
2401
            $WHERE = '';
2402
        }
2403
2404
        if ($databaseName) {
2405
            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2406
        }
2407
2408
        $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
2409
2410
        $return = $this->query($sql);
2411
        \assert($return instanceof Result || $return === false);
2412
2413
        return $return;
2414
    }