Conditions | 5 |
Paths | 3 |
Total Lines | 60 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
42 | public function testMoFilePlurals($filename): void |
||
43 | { |
||
44 | $parser = new Translator($filename); |
||
45 | $expected2 = '%d sekundy'; |
||
46 | if (strpos($filename, 'invalid-formula.mo') !== false || strpos($filename, 'lessplurals.mo') !== false) { |
||
47 | $expected0 = '%d sekunda'; |
||
48 | $expected2 = '%d sekunda'; |
||
49 | } elseif (strpos($filename, 'plurals.mo') !== false || strpos($filename, 'noheader.mo') !== false) { |
||
50 | $expected0 = '%d sekundy'; |
||
51 | } else { |
||
52 | $expected0 = '%d sekund'; |
||
53 | } |
||
54 | |||
55 | $this->assertEquals( |
||
56 | $expected0, |
||
57 | $parser->ngettext( |
||
58 | '%d second', |
||
59 | '%d seconds', |
||
60 | 0 |
||
61 | ) |
||
62 | ); |
||
63 | $this->assertEquals( |
||
64 | '%d sekunda', |
||
65 | $parser->ngettext( |
||
66 | '%d second', |
||
67 | '%d seconds', |
||
68 | 1 |
||
69 | ) |
||
70 | ); |
||
71 | $this->assertEquals( |
||
72 | $expected2, |
||
73 | $parser->ngettext( |
||
74 | '%d second', |
||
75 | '%d seconds', |
||
76 | 2 |
||
77 | ) |
||
78 | ); |
||
79 | $this->assertEquals( |
||
80 | $expected0, |
||
81 | $parser->ngettext( |
||
82 | '%d second', |
||
83 | '%d seconds', |
||
84 | 5 |
||
85 | ) |
||
86 | ); |
||
87 | $this->assertEquals( |
||
88 | $expected0, |
||
89 | $parser->ngettext( |
||
90 | '%d second', |
||
91 | '%d seconds', |
||
92 | 10 |
||
93 | ) |
||
94 | ); |
||
95 | // Non existing string |
||
96 | $this->assertEquals( |
||
97 | '"%d" seconds', |
||
98 | $parser->ngettext( |
||
99 | '"%d" second', |
||
100 | '"%d" seconds', |
||
101 | 10 |
||
102 | ) |
||
223 |