Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit c22f16b

Browse files
committed
- remove checkLanguages with Tests
1 parent 42fa071 commit c22f16b

File tree

2 files changed

+0
-119
lines changed

2 files changed

+0
-119
lines changed

src/DeepL.php

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -31,46 +31,6 @@ class DeepL
3131
*/
3232
const API_URL_RESOURCE_LANGUAGES = 'languages';
3333

34-
/**
35-
* Supported translation source languages
36-
*
37-
* @var array
38-
*/
39-
protected $sourceLanguages = array(
40-
'EN',
41-
'DE',
42-
'FR',
43-
'ES',
44-
'PT',
45-
'IT',
46-
'NL',
47-
'PL',
48-
'RU',
49-
'JA',
50-
'ZH',
51-
);
52-
53-
/**
54-
* Supported translation destination languages
55-
*
56-
* @var array
57-
*/
58-
protected $destinationLanguages = array(
59-
'EN',
60-
'DE',
61-
'FR',
62-
'ES',
63-
'PT',
64-
'PT-PT',
65-
'PT-BR',
66-
'IT',
67-
'NL',
68-
'PL',
69-
'RU',
70-
'JA',
71-
'ZH',
72-
);
73-
7434
/**
7535
* DeepL API Version (v2 is default since 2018)
7636
*
@@ -265,9 +225,6 @@ public function translate(
265225
);
266226
$paramsArray = $this->removeEmptyParams($paramsArray);
267227

268-
// make sure we only accept supported languages
269-
$this->checkLanguages($sourceLanguage, $destinationLanguage);
270-
271228
$url = $this->buildBaseUrl();
272229
$body = $this->buildQuery($paramsArray);
273230

@@ -306,37 +263,6 @@ private function removeEmptyParams($paramsArray)
306263
return $paramsArray;
307264
}
308265

309-
/**
310-
* Check if the given languages are supported
311-
*
312-
* @param string $sourceLanguage
313-
* @param string $destinationLanguage
314-
*
315-
* @return boolean
316-
*
317-
* @throws DeepLException
318-
*/
319-
protected function checkLanguages($sourceLanguage, $destinationLanguage)
320-
{
321-
$sourceLanguage = strtoupper($sourceLanguage);
322-
323-
if (false === in_array($sourceLanguage, $this->sourceLanguages)) {
324-
throw new DeepLException(
325-
sprintf('The language "%s" is not supported as source language.', $sourceLanguage)
326-
);
327-
}
328-
329-
$destinationLanguage = strtoupper($destinationLanguage);
330-
331-
if (false === in_array($destinationLanguage, $this->destinationLanguages)) {
332-
throw new DeepLException(
333-
sprintf('The language "%s" is not supported as destination language.', $destinationLanguage)
334-
);
335-
}
336-
337-
return true;
338-
}
339-
340266
/**
341267
* @param array $paramsArray
342268
*

tests/unit/DeepLTest.php

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@
1414
*/
1515
class DeepLTest extends PHPUnit_Framework_TestCase
1616
{
17-
/**
18-
* Test checkLanguages()
19-
*/
20-
public function testCheckLanguages()
21-
{
22-
$authKey = '123456';
23-
$deepl = new DeepL($authKey);
24-
25-
$checkLanguages = self::getMethod('\BabyMarkt\DeepL\DeepL', 'checkLanguages');
26-
27-
$return = $checkLanguages->invokeArgs($deepl, array('de', 'en'));
28-
29-
$this->assertTrue($return);
30-
}
31-
3217
/**
3318
* Get protected method
3419
*
@@ -48,36 +33,6 @@ protected static function getMethod($className, $methodName)
4833
return $method;
4934
}
5035

51-
/**
52-
* Test checkLanguages() with exception for source language
53-
*/
54-
public function testCheckLanguagesSourceLanguageException()
55-
{
56-
$authKey = '123456';
57-
$deepl = new DeepL($authKey);
58-
59-
$checkLanguages = self::getMethod('\BabyMarkt\DeepL\DeepL', 'checkLanguages');
60-
61-
$this->setExpectedException('\BabyMarkt\DeepL\DeepLException');
62-
63-
$checkLanguages->invokeArgs($deepl, array('fo', 'en'));
64-
}
65-
66-
/**
67-
* Test checkLanguages() with exception for destination language
68-
*/
69-
public function testCheckLanguagesDestinationLanguageException()
70-
{
71-
$authKey = '123456';
72-
$deepl = new DeepL($authKey);
73-
74-
$checkLanguages = self::getMethod('\BabyMarkt\DeepL\DeepL', 'checkLanguages');
75-
76-
$this->setExpectedException('\BabyMarkt\DeepL\DeepLException');
77-
78-
$checkLanguages->invokeArgs($deepl, array('de', 'fo'));
79-
}
80-
8136
/**
8237
* Test translate()
8338
*/

0 commit comments

Comments
 (0)