FOF30\Database\Installer::convertUtf8mb4QueryToUtf8 PHP Method

convertUtf8mb4QueryToUtf8() private method

We use our own method so we can be site it works even on Joomla! 3.4 or earlier, where UTF8MB4 support is not implemented.
private convertUtf8mb4QueryToUtf8 ( string $query ) : string
$query string The query to convert
return string The converted query
    private function convertUtf8mb4QueryToUtf8($query)
    {
        // If it's not an ALTER TABLE or CREATE TABLE command there's nothing to convert
        $beginningOfQuery = substr($query, 0, 12);
        $beginningOfQuery = strtoupper($beginningOfQuery);
        if (!in_array($beginningOfQuery, array('ALTER TABLE ', 'CREATE TABLE'))) {
            return $query;
        }
        // Replace utf8mb4 with utf8
        $from = array('utf8mb4_unicode_ci', 'utf8mb4_', 'utf8mb4');
        $to = array('utf8_general_ci', 'utf8_', 'utf8');
        return str_replace($from, $to, $query);
    }