Code Duplication    Length = 29-29 lines in 2 locations

src/voku/db/Helper.php 2 locations

@@ 289-317 (lines=29) @@
286
     *
287
     * @return string
288
     */
289
    public static function get_mysql_client_version(DB $dbConnection = null): string
290
    {
291
        static $MYSQL_CLIENT_VERSION_CACHE = [];
292
293
        if ($dbConnection === null) {
294
            $dbConnection = DB::getInstance();
295
        }
296
297
        $cacheKey = self::generateCacheKey($dbConnection);
298
299
        if (isset($MYSQL_CLIENT_VERSION_CACHE[$cacheKey])) {
300
            return $MYSQL_CLIENT_VERSION_CACHE[$cacheKey];
301
        }
302
303
        $doctrineConnection = $dbConnection->getDoctrineConnection();
304
        if ($doctrineConnection) {
305
            $doctrineWrappedConnection = $doctrineConnection->getWrappedConnection();
306
            if ($doctrineWrappedConnection instanceof \Doctrine\DBAL\Driver\PDOConnection) {
307
                return $MYSQL_CLIENT_VERSION_CACHE[$cacheKey] = $doctrineWrappedConnection->getAttribute(5); // 5 = PDO::ATTR_CLIENT_VERSION
308
            }
309
        }
310
311
        $mysqli_link = $dbConnection->getLink();
312
        if (!$mysqli_link) {
313
            return '';
314
        }
315
316
        return $MYSQL_CLIENT_VERSION_CACHE[$cacheKey] = (string) \mysqli_get_client_version($mysqli_link);
317
    }
318
319
    /**
320
     * Returns a string representing the version of the MySQL server that the MySQLi extension is connected to.
@@ 326-354 (lines=29) @@
323
     *
324
     * @return string
325
     */
326
    public static function get_mysql_server_version(DB $dbConnection = null): string
327
    {
328
        static $MYSQL_SERVER_VERSION_CACHE = [];
329
330
        if ($dbConnection === null) {
331
            $dbConnection = DB::getInstance();
332
        }
333
334
        $cacheKey = self::generateCacheKey($dbConnection);
335
336
        if (isset($MYSQL_SERVER_VERSION_CACHE[$cacheKey])) {
337
            return $MYSQL_SERVER_VERSION_CACHE[$cacheKey];
338
        }
339
340
        $doctrineConnection = $dbConnection->getDoctrineConnection();
341
        if ($doctrineConnection) {
342
            $doctrineWrappedConnection = $doctrineConnection->getWrappedConnection();
343
            if ($doctrineWrappedConnection instanceof \Doctrine\DBAL\Driver\PDOConnection) {
344
                return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string) $doctrineWrappedConnection->getServerVersion();
345
            }
346
        }
347
348
        $mysqli_link = $dbConnection->getLink();
349
        if (!$mysqli_link) {
350
            return '';
351
        }
352
353
        return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string) \mysqli_get_server_version($mysqli_link);
354
    }
355
356
    /**
357
     * Return all db-fields from a table.