<commit_before><?php

declare(strict_types=1);

namespace Leevel\Database;

/**
 * MySQL 数据库连接.
 */
class Mysql extends Database implements IDatabase
{
    /**
     * {@inheritDoc}
     */
    public function parseDsn(array $option): string
    {
        $dsn = [];
        foreach (['Base', 'Port', 'Socket', 'Charset'] as $method) {
            $dsn[] = $this->{'parse'.$method}($option);
        }

        return implode('', $dsn);
    }

    /**
     * {@inheritDoc}
     */
    public function getTableNames(string $dbName, bool|int $master = false): array
    {
        $sql = 'SHOW TABLES FROM '.$dbName;
        $result = [];
        if (($tables = $this->query($sql, [], $master))) {
            foreach ($tables as $v) {
                $result[] = reset((array) $v);
            }
        }

        return $result;
    }

    /**
     * {@inheritDoc}
     */<commit_msg>修复数据库测试用例<commit_after><?php

declare(strict_types=1);

namespace Leevel\Database;

/**
 * MySQL 数据库连接.
 */
class Mysql extends Database implements IDatabase
{
    /**
     * {@inheritDoc}
     */
    public function parseDsn(array $option): string
    {
        $dsn = [];
        foreach (['Base', 'Port', 'Socket', 'Charset'] as $method) {
            $dsn[] = $this->{'parse'.$method}($option);
        }

        return implode('', $dsn);
    }

    /**
     * {@inheritDoc}
     */
    public function getTableNames(string $dbName, bool|int $master = false): array
    {
        $sql = 'SHOW TABLES FROM '.$dbName;
        $result = [];
        if (($tables = $this->query($sql, [], $master))) {
            foreach ($tables as $v) {
                $result[] = current((array) $v);
            }
        }

        return $result;
    }

    /**
     * {@inheritDoc}
     */
{'fraction_non_alphanumeric': 0.17913832199546487, 'fraction_numerical': 0.0011337868480725624, 'mean_word_length': 1.8887070376432078, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2242578', 'n_tokens_mistral': 576, 'n_tokens_neox': 570, 'n_words': 120}