Code Duplication    Length = 24-24 lines in 2 locations

src/voku/db/Helper.php 2 locations

@@ 271-294 (lines=24) @@
268
     *
269
     * @return string
270
     */
271
    public static function get_mysql_client_version(DB $dbConnection = null): string
272
    {
273
        static $MYSQL_CLIENT_VERSION_CACHE = [];
274
275
        if ($dbConnection === null) {
276
            $dbConnection = DB::getInstance();
277
        }
278
279
        $cacheKey = self::generateCacheKey($dbConnection);
280
281
        if (isset($MYSQL_CLIENT_VERSION_CACHE[$cacheKey])) {
282
            return $MYSQL_CLIENT_VERSION_CACHE[$cacheKey];
283
        }
284
285
        $doctrineConnection = $dbConnection->getDoctrineConnection();
286
        if ($doctrineConnection) {
287
            $doctrineWrappedConnection = $doctrineConnection->getWrappedConnection();
288
            if ($doctrineWrappedConnection instanceof \Doctrine\DBAL\Driver\PDOConnection) {
289
                return $MYSQL_CLIENT_VERSION_CACHE[$cacheKey] = '';
290
            }
291
        }
292
293
        return $MYSQL_CLIENT_VERSION_CACHE[$cacheKey] = (string) \mysqli_get_client_version($dbConnection->getLink());
294
    }
295
296
    /**
297
     * Returns a string representing the version of the MySQL server that the MySQLi extension is connected to.
@@ 303-326 (lines=24) @@
300
     *
301
     * @return string
302
     */
303
    public static function get_mysql_server_version(DB $dbConnection = null): string
304
    {
305
        static $MYSQL_SERVER_VERSION_CACHE = [];
306
307
        if ($dbConnection === null) {
308
            $dbConnection = DB::getInstance();
309
        }
310
311
        $cacheKey = self::generateCacheKey($dbConnection);
312
313
        if (isset($MYSQL_SERVER_VERSION_CACHE[$cacheKey])) {
314
            return $MYSQL_SERVER_VERSION_CACHE[$cacheKey];
315
        }
316
317
        $doctrineConnection = $dbConnection->getDoctrineConnection();
318
        if ($doctrineConnection) {
319
            $doctrineWrappedConnection = $doctrineConnection->getWrappedConnection();
320
            if ($doctrineWrappedConnection instanceof \Doctrine\DBAL\Driver\PDOConnection) {
321
                return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string) $doctrineWrappedConnection->getServerVersion();
322
            }
323
        }
324
325
        return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string) \mysqli_get_server_version($dbConnection->getLink());
326
    }
327
328
    /**
329
     * Return all db-fields from a table.