@@ -159,8 +159,7 @@ public function translate(
159
159
$ destinationLanguage = 'en ' ,
160
160
array $ tagHandling = array (),
161
161
array $ ignoreTags = array ()
162
- )
163
- {
162
+ ) {
164
163
// make sure we only accept supported languages
165
164
$ this ->checkLanguages ($ sourceLanguage , $ destinationLanguage );
166
165
@@ -174,11 +173,9 @@ public function translate(
174
173
175
174
if ($ translationsCount == 0 ) {
176
175
throw new DeepLException ('No translations found. ' );
177
- }
178
- else if ($ translationsCount == 1 ) {
176
+ } elseif ($ translationsCount == 1 ) {
179
177
return $ translationsArray ['translations ' ][0 ]['text ' ];
180
- }
181
- else {
178
+ } else {
182
179
return $ translationsArray ['translations ' ];
183
180
}
184
181
}
@@ -198,13 +195,17 @@ protected function checkLanguages($sourceLanguage, $destinationLanguage)
198
195
$ sourceLanguage = strtoupper ($ sourceLanguage );
199
196
200
197
if (!in_array ($ sourceLanguage , $ this ->sourceLanguages )) {
201
- throw new DeepLException (sprintf ('The language "%s" is not supported as source language. ' , $ sourceLanguage ));
198
+ throw new DeepLException (
199
+ sprintf ('The language "%s" is not supported as source language. ' , $ sourceLanguage )
200
+ );
202
201
}
203
202
204
203
$ destinationLanguage = strtoupper ($ destinationLanguage );
205
204
206
205
if (!in_array ($ destinationLanguage , $ this ->destinationLanguages )) {
207
- throw new DeepLException (sprintf ('The language "%s" is not supported as destination language. ' , $ destinationLanguage ));
206
+ throw new DeepLException (
207
+ sprintf ('The language "%s" is not supported as destination language. ' , $ destinationLanguage )
208
+ );
208
209
}
209
210
210
211
return true ;
@@ -225,8 +226,7 @@ protected function buildUrl(
225
226
$ destinationLanguage ,
226
227
array $ tagHandling = array (),
227
228
array $ ignoreTags = array ()
228
- )
229
- {
229
+ ) {
230
230
// select correct api url
231
231
switch ($ this ->apiVersion ) {
232
232
case 1 :
@@ -271,7 +271,6 @@ protected function buildBody($text)
271
271
}
272
272
273
273
foreach ($ text as $ textElement ) {
274
-
275
274
$ body .= ($ first ? '' : '& ' ) . sprintf (DeepL::API_URL_TEXT , rawurlencode ($ textElement ));
276
275
277
276
if ($ first ) {
@@ -305,8 +304,7 @@ protected function request($url, $body)
305
304
if ($ httpCode != 200 && array_key_exists ($ httpCode , $ this ->errorCodes )) {
306
305
throw new DeepLException ($ this ->errorCodes [$ httpCode ], $ httpCode );
307
306
}
308
- }
309
- else {
307
+ } else {
310
308
throw new DeepLException ('There was a cURL Request Error. ' );
311
309
}
312
310
0 commit comments