Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Genvald committed Nov 22, 2017
1 parent 8d6929a commit c996796
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013-2017 Artem Genvald
Copyright (c) 2013-2017 Artem Henvald

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
12 changes: 6 additions & 6 deletions src/RussianToEnglish.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* This file is part of the Transliteration library
*
* (c) Artem Genvald <[email protected]>
* (c) Artem Henvald <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -15,16 +15,16 @@
/**
* Transliteration from Russian to English.
*
* @author Artem Genvald <[email protected]>
* @author Artem Henvald <[email protected]>
* @author Mykhailo Vilshansky <[email protected]>
* @author Yevgeniy Zholkevskiy <[email protected]>
*
* @see http://www.ufms.spb.ru/desc/pravila-transliteracii-dind-1009.html
*/
class RussianToEnglish implements TransliteratorInterface
{
/** @var array */
private static $russianToEnglishRules = [
/** @const array */
private const RUSSIAN_TO_ENGLISH_RULES = [
'а' => 'a',
'б' => 'b',
'в' => 'v',
Expand Down Expand Up @@ -104,8 +104,8 @@ public static function transliterate(string $russianText): string

if (\mb_strlen($russianText) > 0) {
$transliteratedText = \str_replace(
\array_keys(self::$russianToEnglishRules),
\array_values(self::$russianToEnglishRules),
\array_keys(self::RUSSIAN_TO_ENGLISH_RULES),
\array_values(self::RUSSIAN_TO_ENGLISH_RULES),
$russianText
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Transliterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* This file is part of the Transliteration library
*
* (c) Artem Genvald <[email protected]>
* (c) Artem Henvald <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -15,7 +15,7 @@
/**
* Transliterator.
*
* @author Artem Genvald <[email protected]>
* @author Artem Henvald <[email protected]>
*/
class Transliterator
{
Expand Down
4 changes: 2 additions & 2 deletions src/TransliteratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* This file is part of the Transliteration library
*
* (c) Artem Genvald <[email protected]>
* (c) Artem Henvald <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -15,7 +15,7 @@
/**
* Transliterator Interface.
*
* @author Artem Genvald <[email protected]>
* @author Artem Henvald <[email protected]>
*/
interface TransliteratorInterface
{
Expand Down
12 changes: 6 additions & 6 deletions src/UkrainianToEnglish.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* This file is part of the Transliteration library
*
* (c) Artem Genvald <[email protected]>
* (c) Artem Henvald <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -18,14 +18,14 @@
* According to the rules of transliteration, that are described in the resolution
* of the Cabinet of Ministers of Ukraine №55 dated January 27, 2010.
*
* @author Artem Genvald <[email protected]>
* @author Artem Henvald <[email protected]>
*
* @see http://zakon1.rada.gov.ua/laws/show/55-2010-%D0%BF
*/
class UkrainianToEnglish implements TransliteratorInterface
{
/** @var array */
private static $ukrainianToEnglishRules = [
/** @const array */
private const UKRAINIAN_TO_ENGLISH_RULES = [
'А' => 'A',
'Б' => 'B',
'В' => 'V',
Expand Down Expand Up @@ -109,8 +109,8 @@ public static function transliterate(string $ukrainianText): string
$ukrainianText = \str_replace(['Зг', 'зг'], ['Zgh', 'zgh'], $ukrainianText);
}
$transliteratedText = \str_replace(
\array_keys(self::$ukrainianToEnglishRules),
\array_values(self::$ukrainianToEnglishRules),
\array_keys(self::UKRAINIAN_TO_ENGLISH_RULES),
\array_values(self::UKRAINIAN_TO_ENGLISH_RULES),
$ukrainianText
);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/RussianToEnglishTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* This file is part of the Transliteration library
*
* (c) Artem Genvald <[email protected]>
* (c) Artem Henvald <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -18,12 +18,13 @@
/**
* RussianToEnglish Transliterator Test.
*
* @author Artem Genvald <[email protected]>
* @author Artem Henvald <[email protected]>
* @author Mykhailo Vilshansky <[email protected]>
* @author Yevgeniy Zholkevskiy <[email protected]>
*/
class RussianToEnglishTest extends TestCase
{
/** @var Transliterator */
protected $transliterator;

public function setUp()
Expand Down
8 changes: 4 additions & 4 deletions tests/UkrainianToEnglishTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* This file is part of the Transliteration library
*
* (c) Artem Genvald <[email protected]>
* (c) Artem Henvald <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -18,10 +18,11 @@
/**
* UkrainianToEnglish Transliterator Test.
*
* @author Artem Genvald <[email protected]>
* @author Artem Henvald <[email protected]>
*/
class UkrainianToEnglishTest extends TestCase
{
/** @var Transliterator */
protected $transliterator;

public function setUp()
Expand All @@ -42,7 +43,6 @@ public function testTransliterationFromUkrainianToEnglish(string $ukrainianText,
public function alphabetProvider(): array
{
return [
// Ukrainian alphabet
['А', 'A'],
['Б', 'B'],
['В', 'V'],
Expand Down Expand Up @@ -114,8 +114,8 @@ public function alphabetProvider(): array

public function officialExamplesProvider(): array
{
// Examples of transliteration form the resolution of the Cabinet of Ministers of Ukraine №55 (27.01.2010)
return [
// Examples of transliteration form the resolution of the Cabinet of Ministers of Ukraine №55 (27.01.2010)
// Аа
['Алушта', 'Alushta'],
['Андрій', 'Andrii'],
Expand Down

0 comments on commit c996796

Please sign in to comment.