| Conditions | 3 |
| Paths | 5 |
| Total Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 43 | public function translate(string $string) : string |
||
| 44 | { |
||
| 45 | try { |
||
| 46 | sleep(random_int(config('auto-translate.simple_google_translator.sleep_between_requests')[0], config('auto-translate.simple_google_translator.sleep_between_requests')[1])); |
||
| 47 | |||
| 48 | return $this->translator->translate($string); |
||
| 49 | } catch (\Throwable $th) { |
||
| 50 | if ($th->getMessage() === 'Return value of Stichoza\GoogleTranslate\GoogleTranslate::translate() must be of the type string, null returned') { |
||
| 51 | throw LanguageCodeNotExist::throw($this->source, $this->target); |
||
| 52 | } |
||
| 53 | } |
||
| 54 | } |
||
| 55 | } |
||
| 56 |