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

Commit fbc7997

Browse files
committed
- revert from ReflectionMethod to Array, because MessDetection did not like it.
1 parent 3e3ba23 commit fbc7997

File tree

1 file changed

+14
-33
lines changed

1 file changed

+14
-33
lines changed

src/DeepL.php

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public function languages()
188188
* @return array
189189
* @throws DeepLException
190190
*
191-
* @SuppressWarnings(PHPMD.UnusedParameters)
191+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
192192
*/
193193
public function translate(
194194
$text,
@@ -206,14 +206,20 @@ public function translate(
206206
if (is_array($tagHandling)) {
207207
throw new \InvalidArgumentException('$tagHandling must be of type String in V2 of DeepLLibrary');
208208
}
209-
$paramsArray = array();
210-
$reflection = new ReflectionMethod('Babymarkt\DeepL\DeepL', 'translate');
209+
$paramsArray = array(
210+
'text' => $text,
211+
'source_lang' => $sourceLang,
212+
'target_lang' => $targetLang,
213+
'splitting_tags' => $splittingTags,
214+
'non_splitting_tags' => $nonSplittingTags,
215+
'ignore_tags' => $ignoreTags,
216+
'tag_handling' => $tagHandling,
217+
'formality' => $formality,
218+
'split_sentences' => $splitSentences,
219+
'preserve_formatting' => $preserveFormatting,
220+
'outline_detection' => $outlineDetection,
221+
);
211222

212-
foreach ($reflection->getParameters() as $param) {
213-
$paramName = $param->name;
214-
$paraKey = $this->camelToSnake($paramName);
215-
$paramsArray[$paraKey] = $$paramName;
216-
}
217223
$paramsArray = $this->removeEmptyParams($paramsArray);
218224
$url = $this->buildBaseUrl();
219225
$body = $this->buildQuery($paramsArray);
@@ -283,29 +289,4 @@ protected function buildQuery($paramsArray)
283289

284290
return $body;
285291
}
286-
287-
288-
/**
289-
* @param string $subject
290-
*
291-
* @return string
292-
*/
293-
private function camelToSnake($subject)
294-
{
295-
if (preg_match('/[A-Z]/', $subject) === 0) {
296-
return $subject;
297-
}
298-
$pattern = '/([a-z])([A-Z])/';
299-
$snakeString = strtolower(
300-
preg_replace_callback(
301-
$pattern,
302-
function ($match) {
303-
return $match[1]."_".strtolower($match[2]);
304-
},
305-
$subject
306-
)
307-
);
308-
309-
return $snakeString;
310-
}
311292
}

0 commit comments

Comments
 (0)