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