Conditions | 1 |
Paths | 1 |
Total Lines | 99 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
94 | public function testReportsNoNewTranslationMessages(): void |
||
95 | { |
||
96 | \file_put_contents( |
||
97 | __DIR__.'/../app/Resources/translations/messages.sv.xlf', |
||
98 | <<<'XML' |
||
99 | <?xml version="1.0" encoding="utf-8"?> |
||
100 | <xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="sv"> |
||
101 | <file id="messages.sv"> |
||
102 | <unit id="gwCXP88" name="translated.title"> |
||
103 | <notes> |
||
104 | <note category="file-source" priority="1">Resources/views/translated.html.twig:5</note> |
||
105 | <note category="state" priority="1">new</note> |
||
106 | </notes> |
||
107 | <segment> |
||
108 | <source>translated.title</source> |
||
109 | <target>My translated title</target> |
||
110 | </segment> |
||
111 | </unit> |
||
112 | <unit id="MVOZYWq" name="translated.heading"> |
||
113 | <notes> |
||
114 | <note category="file-source" priority="1">Resources/views/translated.html.twig:8</note> |
||
115 | </notes> |
||
116 | <segment> |
||
117 | <source>translated.heading</source> |
||
118 | <target>My translated heading</target> |
||
119 | </segment> |
||
120 | </unit> |
||
121 | <unit id="bJFCP77" name="translated.paragraph0"> |
||
122 | <notes> |
||
123 | <note category="file-source" priority="1">Resources/views/translated.html.twig:9</note> |
||
124 | </notes> |
||
125 | <segment> |
||
126 | <source>translated.paragraph0</source> |
||
127 | <target>My translated paragraph0</target> |
||
128 | </segment> |
||
129 | </unit> |
||
130 | <unit id="1QAmWwr" name="translated.paragraph1"> |
||
131 | <notes> |
||
132 | <note category="file-source" priority="1">Resources/views/translated.html.twig:9</note> |
||
133 | </notes> |
||
134 | <segment> |
||
135 | <source>translated.paragraph1</source> |
||
136 | <target>My translated paragraph1</target> |
||
137 | </segment> |
||
138 | </unit> |
||
139 | <unit id="7AdXS54" name="translated.paragraph2"> |
||
140 | <notes> |
||
141 | <note category="file-source" priority="1">Resources/views/translated.html.twig:11</note> |
||
142 | <note category="state" priority="1">new</note> |
||
143 | </notes> |
||
144 | <segment> |
||
145 | <source>translated.paragraph2</source> |
||
146 | <target>My translated paragraph2</target> |
||
147 | </segment> |
||
148 | </unit> |
||
149 | <unit id="WvnvT8X" name="localized.email"> |
||
150 | <notes> |
||
151 | <note category="file-source" priority="1">Resources/views/translated.html.twig:12</note> |
||
152 | <note category="file-source" priority="1">Resources/views/translated.html.twig:12</note> |
||
153 | <note category="state" priority="1">new</note> |
||
154 | </notes> |
||
155 | <segment> |
||
156 | <source>localized.email</source> |
||
157 | <target>My localized email</target> |
||
158 | </segment> |
||
159 | </unit> |
||
160 | <unit id="ETjQiEP" name="translated.attribute"> |
||
161 | <notes> |
||
162 | <note category="file-source" priority="1">Resources/views/translated.html.twig:14</note> |
||
163 | <note category="state" priority="1">new</note> |
||
164 | </notes> |
||
165 | <segment> |
||
166 | <source>translated.attribute</source> |
||
167 | <target>My translated attribute</target> |
||
168 | </segment> |
||
169 | </unit> |
||
170 | <unit id="GO15Lkx" name="not.in.source"> |
||
171 | <notes> |
||
172 | <note category="state" priority="1">obsolete</note> |
||
173 | </notes> |
||
174 | <segment> |
||
175 | <source>not.in.source</source> |
||
176 | <target>This is not in the source code</target> |
||
177 | </segment> |
||
178 | </unit> |
||
179 | </file> |
||
180 | </xliff> |
||
181 | XML |
||
182 | ); |
||
183 | |||
184 | $commandTester = new CommandTester($this->application->find('translation:check-missing')); |
||
185 | |||
186 | $commandTester->execute(['locale' => 'sv', 'configuration' => 'app']); |
||
187 | |||
188 | $this->assertStringContainsString( |
||
189 | 'No new translation messages', |
||
190 | $commandTester->getDisplay() |
||
191 | ); |
||
192 | $this->assertSame(0, $commandTester->getStatusCode()); |
||
193 | } |
||
195 |