From de3f14d8421d996015acae73ef8eb528a2305efb Mon Sep 17 00:00:00 2001 From: ChrisKonnertz Date: Mon, 2 Oct 2017 14:36:04 +0200 Subject: [PATCH] Switch order of methods --- src/ChrisKonnertz/DeepLy/DeepLy.php | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/ChrisKonnertz/DeepLy/DeepLy.php b/src/ChrisKonnertz/DeepLy/DeepLy.php index b3cf161..5582015 100644 --- a/src/ChrisKonnertz/DeepLy/DeepLy.php +++ b/src/ChrisKonnertz/DeepLy/DeepLy.php @@ -104,24 +104,6 @@ public function __construct() $this->httpClient = new CurlHttpClient($this->protocol); } - /** - * Tries to detect the language of a text and returns its language code. - * The language of the text has to be one of the supported languages or the result will be incorrect. - * This method might throw an exception so you should wrap it in a try-catch-block. - * - * @param string $text The text you want to analyze - * @return string|null Returns a language code from the self::LANG_CODES array or null - * @throws \Exception - */ - public function detectLanguage($text) - { - // Note: We always use English as the target language. if the source language is English as well, - // DeepL automatically seems to set the target language to French so this is not a problem. - $translationBag = $this->requestTranslation($text, self::LANG_EN); - - return $translationBag->getSourceLanguage(); - } - /** * Uses the DeepL API to split a text into a string array of sentences. * @@ -158,6 +140,24 @@ public function splitText($text, $from = self::LANG_AUTO) return $sentences; } + /** + * Tries to detect the language of a text and returns its language code. + * The language of the text has to be one of the supported languages or the result will be incorrect. + * This method might throw an exception so you should wrap it in a try-catch-block. + * + * @param string $text The text you want to analyze + * @return string|null Returns a language code from the self::LANG_CODES array or null + * @throws \Exception + */ + public function detectLanguage($text) + { + // Note: We always use English as the target language. if the source language is English as well, + // DeepL automatically seems to set the target language to French so this is not a problem. + $translationBag = $this->requestTranslation($text, self::LANG_EN); + + return $translationBag->getSourceLanguage(); + } + /** * Requests a translation from the API. Returns a TranslationBag object. * ATTENTION: The target language parameter is followed by the source language parameter!