Code Duplication    Length = 38-39 lines in 2 locations

lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php 1 location

@@ 209-247 (lines=39) @@
206
    /**
207
     * {@inheritdoc}
208
     */
209
    public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
210
    {
211
        // do not try fetching from the statement if it's not expected to contain result
212
        // in order to prevent exceptional situation
213
        if (!$this->result) {
214
            return false;
215
        }
216
217
        $fetchMode = $fetchMode ?: $this->_defaultFetchMode;
218
        switch ($fetchMode) {
219
            case \PDO::FETCH_BOTH:
220
                return db2_fetch_both($this->_stmt);
221
            case \PDO::FETCH_ASSOC:
222
                return db2_fetch_assoc($this->_stmt);
223
            case \PDO::FETCH_CLASS:
224
                $className = $this->defaultFetchClass;
225
                $ctorArgs  = $this->defaultFetchClassCtorArgs;
226
227
                if (func_num_args() >= 2) {
228
                    $args      = func_get_args();
229
                    $className = $args[1];
230
                    $ctorArgs  = isset($args[2]) ? $args[2] : [];
231
                }
232
233
                $result = db2_fetch_object($this->_stmt);
234
235
                if ($result instanceof \stdClass) {
236
                    $result = $this->castObject($result, $className, $ctorArgs);
237
                }
238
239
                return $result;
240
            case \PDO::FETCH_NUM:
241
                return db2_fetch_array($this->_stmt);
242
            case \PDO::FETCH_OBJ:
243
                return db2_fetch_object($this->_stmt);
244
            default:
245
                throw new DB2Exception('Given Fetch-Style ' . $fetchMode . ' is not supported.');
246
        }
247
    }
248
249
    /**
250
     * {@inheritdoc}

lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php 1 location

@@ 197-234 (lines=38) @@
194
     *
195
     * @throws SQLAnywhereException
196
     */
197
    public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
198
    {
199
        if ( ! is_resource($this->result)) {
200
            return false;
201
        }
202
203
        $fetchMode = $fetchMode ?: $this->defaultFetchMode;
204
205
        switch ($fetchMode) {
206
            case PDO::FETCH_ASSOC:
207
                return sasql_fetch_assoc($this->result);
208
            case PDO::FETCH_BOTH:
209
                return sasql_fetch_array($this->result, SASQL_BOTH);
210
            case PDO::FETCH_CLASS:
211
                $className = $this->defaultFetchClass;
212
                $ctorArgs  = $this->defaultFetchClassCtorArgs;
213
214
                if (func_num_args() >= 2) {
215
                    $args      = func_get_args();
216
                    $className = $args[1];
217
                    $ctorArgs  = isset($args[2]) ? $args[2] : [];
218
                }
219
220
                $result = sasql_fetch_object($this->result);
221
222
                if ($result instanceof \stdClass) {
223
                    $result = $this->castObject($result, $className, $ctorArgs);
224
                }
225
226
                return $result;
227
            case PDO::FETCH_NUM:
228
                return sasql_fetch_row($this->result);
229
            case PDO::FETCH_OBJ:
230
                return sasql_fetch_object($this->result);
231
            default:
232
                throw new SQLAnywhereException('Fetch mode is not supported: ' . $fetchMode);
233
        }
234
    }
235
236
    /**
237
     * {@inheritdoc}