Completed
Push — master ( b679d6...f61b55 )
by Artem
01:51
created

RussianToEnglishTest::dataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 69
Code Lines 65

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 69
rs 9.2083
cc 1
eloc 65
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
 * This file is part of the Transliteration library
4
 *
5
 * (c) Mykhailo Vilshansky <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Tests\Fresh\Transliteration;
11
12
use Fresh\Transliteration\Transliterator;
13
14
/**
15
 * RussianToEnglish Transliterator Test
16
 *
17
 * @author Mykhailo Vilshansky <[email protected]>
18
 */
19
class RussianToEnglishTest extends \PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @var Transliterator
23
     */
24
    protected $transliterator;
25
26
    /**
27
     * Set up environment
28
     */
29
    public function setUp()
30
    {
31
        $this->transliterator = new Transliterator();
32
    }
33
34
    /**
35
     * Test transliteration from Russian to English
36
     *
37
     * @param array $russianText        Russian text
38
     * @param array $transliteratedText Expected transliterated text
39
     *
40
     * @test
41
     * @covers       \Fresh\Transliteration\Transliterator
42
     * @covers       \Fresh\Transliteration\RussianToEnglish
43
     * @dataProvider dataProvider
44
     */
45
    public function transliterationFromRussianToEnglish($russianText, $transliteratedText)
46
    {
47
        $this->assertEquals($transliteratedText, $this->transliterator->ruToEn($russianText));
0 ignored issues
show
Documentation introduced by
$russianText is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
48
    }
49
50
    /**
51
     * Data provider for transliteration from Russian to English
52
     *
53
     * @return array
54
     */
55
    public function dataProvider()
56
    {
57
        return [
58
            // Russian alphabet
59
            ['а', 'a'],
60
            ['б', 'b'],
61
            ['в', 'v'],
62
            ['г', 'g'],
63
            ['д', 'd'],
64
            ['е', 'e'],
65
            ['ё', 'e'],
66
            ['ж', 'zh'],
67
            ['з', 'z'],
68
            ['и', 'i'],
69
            ['й', 'y'],
70
            ['к', 'k'],
71
            ['л', 'l'],
72
            ['м', 'm'],
73
            ['н', 'n'],
74
            ['о', 'o'],
75
            ['п', 'p'],
76
            ['р', 'r'],
77
            ['с', 's'],
78
            ['т', 't'],
79
            ['у', 'u'],
80
            ['ф', 'f'],
81
            ['х', 'h'],
82
            ['ц', 'ts'],
83
            ['ч', 'ch'],
84
            ['ш', 'sh'],
85
            ['щ', 'sht'],
86
            ['ь', ''],
87
            ['ы', 'y'],
88
            ['ъ', ''],
89
            ['ю', 'yu'],
90
            ['я', 'ya'],
91
            ['А', 'A'],
92
            ['Б', 'B'],
93
            ['В', 'V'],
94
            ['Г', 'G'],
95
            ['Д', 'D'],
96
            ['Е', 'E'],
97
            ['Ж', 'Zh'],
98
            ['З', 'Z'],
99
            ['И', 'I'],
100
            ['Й', 'Y'],
101
            ['К', 'K'],
102
            ['Л', 'L'],
103
            ['М', 'M'],
104
            ['Н', 'N'],
105
            ['О', 'O'],
106
            ['П', 'P'],
107
            ['Р', 'R'],
108
            ['С', 'S'],
109
            ['Т', 'T'],
110
            ['У', 'U'],
111
            ['Ф', 'F'],
112
            ['Х', 'H'],
113
            ['Ц', 'Ts'],
114
            ['Ч', 'Ch'],
115
            ['Ш', 'Sh'],
116
            ['Щ', 'Sht'],
117
            ['Ь', ''],
118
            ['Ы', 'Y'],
119
            ['Ъ', ''],
120
            ['Ю', 'Yu'],
121
            ['Я', 'Ya'],
122
        ];
123
    }
124
}
125