public static function getConnection(StemSettings $settings)
    {
        $connectionHash = $settings->host . $settings->port . $settings->username . $settings->database;

        if (!isset(PdoRepository::$connections[$connectionHash])) {
            try {
                $pdo = new \PDO(
                    "mysql:host=" . $settings->host . ";port=" . $settings->port . ";dbname=" . $settings->database . ";charset=utf8",
                    $settings->username,
                    $settings->password,
                    array_merge(
                        [\PDO::ERRMODE_EXCEPTION => true, \PDO::MYSQL_ATTR_FOUND_ROWS => true],
                        $settings->pdoOptions
                    )
                );

                $timeZone = $pdo->query("SELECT @@time_zone as tz, @@system_time_zone as stz");
                if ($timeZone->rowCount()) {
                    $timezones = $timeZone->fetch(\PDO::FETCH_ASSOC);
                    if($timezones['tz'] === 'SYSTEM'){
                        $settings->repositoryTimeZone = new \DateTimeZone($timezones['stz']);
                    } else {
                        $settings->repositoryTimeZone = new \DateTimeZone($timezones['tz']);
                    }
                }

                if ($settings->charset) {
                    $statement = $pdo->prepare("SET NAMES :charset");
                    $statement->execute(['charset' => $settings->charset]);
                }
            } catch (\PDOException $er) {
                throw new RepositoryConnectionException("MySql", $er);
            }

            PdoRepository::$connections[$connectionHash] = $pdo;
        }

        return PdoRepository::$connections[$connectionHash];
    }