2
2
3
3
namespace Stichoza \GoogleTranslate ;
4
4
5
- use BadMethodCallException ;
6
5
use ErrorException ;
7
6
use GuzzleHttp \Client ;
8
7
use GuzzleHttp \Exception \RequestException ;
@@ -121,7 +120,7 @@ public function __construct(string $target = 'en', string $source = null, array
121
120
* @param string $target Language code
122
121
* @return GoogleTranslate
123
122
*/
124
- public function setTarget (string $ target ) : self
123
+ public function setTarget (string $ target ): self
125
124
{
126
125
$ this ->target = $ target ;
127
126
return $ this ;
@@ -133,7 +132,7 @@ public function setTarget(string $target) : self
133
132
* @param string|null $source Language code
134
133
* @return GoogleTranslate
135
134
*/
136
- public function setSource (string $ source = null ) : self
135
+ public function setSource (string $ source = null ): self
137
136
{
138
137
$ this ->source = $ source ?? 'auto ' ;
139
138
return $ this ;
@@ -145,7 +144,7 @@ public function setSource(string $source = null) : self
145
144
* @param string $url Google Translate URL base
146
145
* @return GoogleTranslate
147
146
*/
148
- public function setUrl (string $ url ) : self
147
+ public function setUrl (string $ url ): self
149
148
{
150
149
$ this ->url = $ url ;
151
150
return $ this ;
@@ -157,7 +156,7 @@ public function setUrl(string $url) : self
157
156
* @param array $options guzzleHttp client options.
158
157
* @return GoogleTranslate
159
158
*/
160
- public function setOptions (array $ options = null ) : self
159
+ public function setOptions (array $ options = null ): self
161
160
{
162
161
$ this ->options = $ options ?? [];
163
162
return $ this ;
@@ -169,7 +168,7 @@ public function setOptions(array $options = null) : self
169
168
* @param TokenProviderInterface $tokenProvider
170
169
* @return GoogleTranslate
171
170
*/
172
- public function setTokenProvider (TokenProviderInterface $ tokenProvider ) : self
171
+ public function setTokenProvider (TokenProviderInterface $ tokenProvider ): self
173
172
{
174
173
$ this ->tokenProvider = $ tokenProvider ;
175
174
return $ this ;
@@ -218,7 +217,7 @@ public static function trans(string $string, string $target = 'en', string $sour
218
217
* @throws ErrorException If the HTTP request fails
219
218
* @throws UnexpectedValueException If received data cannot be decoded
220
219
*/
221
- public function translate (string $ string ) : string
220
+ public function translate (string $ string ): string
222
221
{
223
222
/*
224
223
* if source lang and target lang are the same
@@ -293,7 +292,7 @@ public function translate(string $string) : string
293
292
* @throws UnexpectedValueException If received data cannot be decoded
294
293
* @return array|string Response
295
294
*/
296
- public function getResponse (string $ string ) : array
295
+ public function getResponse (string $ string ): array
297
296
{
298
297
$ queryArray = array_merge ($ this ->urlParams , [
299
298
'sl ' => $ this ->source ,
@@ -331,7 +330,7 @@ public function getResponse(string $string) : array
331
330
* @param string $lang Langauge code to verify
332
331
* @return bool
333
332
*/
334
- protected function isValidLocale (string $ lang ) : bool
333
+ protected function isValidLocale (string $ lang ): bool
335
334
{
336
335
return (bool ) preg_match ('/^([a-z]{2})(-[A-Z]{2})?$/ ' , $ lang );
337
336
}
0 commit comments