zvermafia/transliteration 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zvermafia/transliteration

Composer 安装命令:

composer require zvermafia/transliteration

包简介

Uzbek latin <=> cyrillic transliterator

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Uzbek latin <=> cyrillic transliterator. Under the hood it uses some online transliteration services. But it's extendable!

Navigation by sections

Install

Via Composer

$ composer require zvermafia/uzbek-transliterator

Usage

Out of the box there are two implementations for your choice:

  1. Zvermafia\Transliteration\AlifTransliterator which uses an alif.uz online transliteration service's API;
  2. Zvermafia\Transliteration\LotinTransliterator which uses a lotin.uz online transliteration service's API;

Also you can implement your own class which will use another service's API or won't use any services' API and does all the job by itself.

require __DIR__ . "/vendor/autoload.php";

// Initialize the object
$transliterator = new Zvermafia\Transliteration\AlifTransliterator(); // or you can use LotinTransliterator

$transliterator->setText("Salom, dunyo!")
    ->toCyrillic()
    ->translit();

echo $transliterator->getResult(); // it will output: Салом, дунё!

Make your own implementation (extending)

If these two already exist implementations aren't enough for you, then you can extend functionalities of this package by implementing your own transliterator class. If so there are three possible ways:

  1. Create a class by implementing a Zvermafia\Transliteration\Interfaces\TransliteratorInterface interface. In this case you must realize all the methods defined in the interface from scratch by yourself;
  2. This is the recommended way (if you're not going to use third party APIs with HTTP). Create a class by extending Zvermafia\Transliteration\Abstracts\TransliteratorAbstract abstract class. In this case you must realize only that methods which aren't already realized by the abstract class. The abstract class already realized common methods of the interface;
  3. This one is similar to the previous way. Because in this case you'll use a Zvermafia\Transliteration\Abstracts\HttpTransliteratorAbstract abstract class which is extends by the Zvermafia\Transliteration\Abstracts\TransliteratorAbstract. But what is the difference? The difference is in this abstract class realized some common methods which will work with the HTTP through the cURL extension. So you must only configure some specific HTTP request parameters to work with an API.

So here are examples by the points.

An example for the point number 1:

<?php

namespace Whatever\Namespace;

use Zvermafia\Transliteration\Interfaces\TransliteratorInterface;

// point #1
class MyTransliterator implements TransliteratorInterface
{
    // realize all the methods defined in the interface (
}

An example for the point number 2:

<?php

namespace Whatever\Namespace;

use Zvermafia\Transliteration\Abstracts\TransliteratorAbstract;
use Zvermafia\Transliteration\Interfaces\TransliteratorInterface;

// point #1
class MyTransliterator extends TransliteratorAbstract
{
    public function translit(): : TransliteratorInterface
    {
        $text = $this->getText();
        // $result = ... // here translit the text
        $this->setResult($result);

        return $this;
    }
}

An example for the point number 3:

As examples for this point you can see source codes of Zvermafia\Transliteration\AlifTransliterator and Zvermafia\Transliteration\LotinTransliterator.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email mohirjon@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固