-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Artem Genvald
committed
Nov 22, 2017
1 parent
8d6929a
commit c996796
Showing
7 changed files
with
24 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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', | ||
|
@@ -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 | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -15,7 +15,7 @@ | |
/** | ||
* Transliterator. | ||
* | ||
* @author Artem Genvald <[email protected]> | ||
* @author Artem Henvald <[email protected]> | ||
*/ | ||
class Transliterator | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -15,7 +15,7 @@ | |
/** | ||
* Transliterator Interface. | ||
* | ||
* @author Artem Genvald <[email protected]> | ||
* @author Artem Henvald <[email protected]> | ||
*/ | ||
interface TransliteratorInterface | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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', | ||
|
@@ -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 | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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() | ||
|
@@ -42,7 +43,6 @@ public function testTransliterationFromUkrainianToEnglish(string $ukrainianText, | |
public function alphabetProvider(): array | ||
{ | ||
return [ | ||
// Ukrainian alphabet | ||
['А', 'A'], | ||
['Б', 'B'], | ||
['В', 'V'], | ||
|
@@ -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'], | ||
|