コード例 #1
0
ファイル: Codec.php プロジェクト: iHunt101/phlite
        return $rv;
    }
    static function register($search_func)
    {
        if (!is_callable($search_func)) {
            throw new InvalidArgumentException('Only callables can be registered');
        }
        static::$registry[] = $search_func;
    }
    static function lookup($encoding)
    {
        $encoding = strtolower($encoding);
        foreach (static::$registry as $f) {
            if ($codec = $f($encoding)) {
                return $codec;
            }
        }
        throw new DomainException($encoding . ': Unable to find codec');
    }
    /**
     * Convenience method to load a module from the Encodings/ folder
     */
    static function load($module)
    {
        include_once "Encodings/{$module}.php";
    }
}
// Load standard encodings
Codec::load('basic');
Codec::load('mbstring');