@@ -72,11 +72,11 @@ |
||
| 72 | 72 | { |
| 73 | 73 | $flip = $separator == '-' ? '_' : '-'; |
| 74 | 74 | |
| 75 | - $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); |
|
| 75 | + $title = preg_replace('![' . preg_quote($flip) . ']+!u', $separator, $title); |
|
| 76 | 76 | |
| 77 | - $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title)); |
|
| 77 | + $title = preg_replace('![^' . preg_quote($separator) . '\pL\pN\s]+!u', '', mb_strtolower($title)); |
|
| 78 | 78 | |
| 79 | - $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title); |
|
| 79 | + $title = preg_replace('![' . preg_quote($separator) . '\s]+!u', $separator, $title); |
|
| 80 | 80 | |
| 81 | 81 | return trim($title, $separator); |
| 82 | 82 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | private function getTranslatedText($text) |
| 67 | 67 | { |
| 68 | - if ( $this->isEnglish($text) ) { |
|
| 68 | + if ($this->isEnglish($text)) { |
|
| 69 | 69 | return $text; |
| 70 | 70 | } |
| 71 | 71 | $text = $this->removeSegment($text); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | private function getTranslation(array $translateResponse) |
| 84 | 84 | { |
| 85 | - if ((int) $translateResponse['errorCode'] === 0 ) { |
|
| 85 | + if ((int) $translateResponse['errorCode'] === 0) { |
|
| 86 | 86 | return $this->getTranslatedTextFromResponse($translateResponse); |
| 87 | 87 | } |
| 88 | 88 | throw new TranslationErrorException('Translate error, error_code : ' . $translateResponse['errorCode'] . '. Refer url: http://ai.youdao.com/docs/api.s'); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | private function isEnglish($text) |
| 123 | 123 | { |
| 124 | - if ( preg_match("/\p{Han}+/u", $text) ) { |
|
| 124 | + if (preg_match("/\p{Han}+/u", $text)) { |
|
| 125 | 125 | return false; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | public function register() |
| 33 | 33 | { |
| 34 | - $this->app->singleton('translug', function () { |
|
| 34 | + $this->app->singleton('translug', function() { |
|
| 35 | 35 | return new Translation(new Client(), config('services.youdao')); |
| 36 | 36 | }); |
| 37 | 37 | } |