From c996796cf3560d8e9a344429625c57e4aecad388 Mon Sep 17 00:00:00 2001 From: Artem Genvald Date: Wed, 22 Nov 2017 11:13:37 +0200 Subject: [PATCH] Refactoring --- LICENSE | 2 +- src/RussianToEnglish.php | 12 ++++++------ src/Transliterator.php | 4 ++-- src/TransliteratorInterface.php | 4 ++-- src/UkrainianToEnglish.php | 12 ++++++------ tests/RussianToEnglishTest.php | 5 +++-- tests/UkrainianToEnglishTest.php | 8 ++++---- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/LICENSE b/LICENSE index bd9ccdc..36cc438 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/src/RussianToEnglish.php b/src/RussianToEnglish.php index fea177d..26be14f 100644 --- a/src/RussianToEnglish.php +++ b/src/RussianToEnglish.php @@ -4,7 +4,7 @@ /* * This file is part of the Transliteration library * - * (c) Artem Genvald + * (c) Artem Henvald * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +15,7 @@ /** * Transliteration from Russian to English. * - * @author Artem Genvald + * @author Artem Henvald * @author Mykhailo Vilshansky * @author Yevgeniy Zholkevskiy * @@ -23,8 +23,8 @@ */ 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 ); } diff --git a/src/Transliterator.php b/src/Transliterator.php index bb20b7e..556cce8 100644 --- a/src/Transliterator.php +++ b/src/Transliterator.php @@ -4,7 +4,7 @@ /* * This file is part of the Transliteration library * - * (c) Artem Genvald + * (c) Artem Henvald * * 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 + * @author Artem Henvald */ class Transliterator { diff --git a/src/TransliteratorInterface.php b/src/TransliteratorInterface.php index ec72909..ea17064 100644 --- a/src/TransliteratorInterface.php +++ b/src/TransliteratorInterface.php @@ -4,7 +4,7 @@ /* * This file is part of the Transliteration library * - * (c) Artem Genvald + * (c) Artem Henvald * * 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 + * @author Artem Henvald */ interface TransliteratorInterface { diff --git a/src/UkrainianToEnglish.php b/src/UkrainianToEnglish.php index e0213f4..1886204 100644 --- a/src/UkrainianToEnglish.php +++ b/src/UkrainianToEnglish.php @@ -4,7 +4,7 @@ /* * This file is part of the Transliteration library * - * (c) Artem Genvald + * (c) Artem Henvald * * 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 + * @author Artem Henvald * * @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 ); } diff --git a/tests/RussianToEnglishTest.php b/tests/RussianToEnglishTest.php index f050f1d..59ddd5e 100644 --- a/tests/RussianToEnglishTest.php +++ b/tests/RussianToEnglishTest.php @@ -4,7 +4,7 @@ /* * This file is part of the Transliteration library * - * (c) Artem Genvald + * (c) Artem Henvald * * 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 + * @author Artem Henvald * @author Mykhailo Vilshansky * @author Yevgeniy Zholkevskiy */ class RussianToEnglishTest extends TestCase { + /** @var Transliterator */ protected $transliterator; public function setUp() diff --git a/tests/UkrainianToEnglishTest.php b/tests/UkrainianToEnglishTest.php index c506aea..d64b4dd 100644 --- a/tests/UkrainianToEnglishTest.php +++ b/tests/UkrainianToEnglishTest.php @@ -4,7 +4,7 @@ /* * This file is part of the Transliteration library * - * (c) Artem Genvald + * (c) Artem Henvald * * 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 + * @author Artem Henvald */ 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'],