<?php

if (! defined('ABSPATH')) {
    exit;
} class PufferGo_Slug_Helper
{
    private static $pinyin_table = null;

    public static function slug_for_title(string $title): string
    {
        return sanitize_title(self::transliterate($title));
    }

    public static function transliterate(string $text): string
    {
        if ($text === '') {
            return $text;
        } $table = self::get_table();

        if (empty($table)) {
            return $text;
        }

return strtr($text, $table);
    }

    private static function get_table(): array
    {
        if (self::$pinyin_table === null) {
            $file = PUFFERGO_PLUGIN_DIR . '/php/lib/pinyin-table.php';
            self::$pinyin_table = is_readable($file) ? (array) require $file : array();
        }

return self::$pinyin_table;
    }
}
