22
33namespace Stichoza \GoogleTranslate ;
44
5- use BadMethodCallException ;
65use ErrorException ;
76use GuzzleHttp \Client ;
87use GuzzleHttp \Exception \RequestException ;
@@ -121,7 +120,7 @@ public function __construct(string $target = 'en', string $source = null, array
121120 * @param string $target Language code
122121 * @return GoogleTranslate
123122 */
124- public function setTarget (string $ target ) : self
123+ public function setTarget (string $ target ): self
125124 {
126125 $ this ->target = $ target ;
127126 return $ this ;
@@ -133,7 +132,7 @@ public function setTarget(string $target) : self
133132 * @param string|null $source Language code
134133 * @return GoogleTranslate
135134 */
136- public function setSource (string $ source = null ) : self
135+ public function setSource (string $ source = null ): self
137136 {
138137 $ this ->source = $ source ?? 'auto ' ;
139138 return $ this ;
@@ -145,7 +144,7 @@ public function setSource(string $source = null) : self
145144 * @param string $url Google Translate URL base
146145 * @return GoogleTranslate
147146 */
148- public function setUrl (string $ url ) : self
147+ public function setUrl (string $ url ): self
149148 {
150149 $ this ->url = $ url ;
151150 return $ this ;
@@ -157,7 +156,7 @@ public function setUrl(string $url) : self
157156 * @param array $options guzzleHttp client options.
158157 * @return GoogleTranslate
159158 */
160- public function setOptions (array $ options = null ) : self
159+ public function setOptions (array $ options = null ): self
161160 {
162161 $ this ->options = $ options ?? [];
163162 return $ this ;
@@ -169,7 +168,7 @@ public function setOptions(array $options = null) : self
169168 * @param TokenProviderInterface $tokenProvider
170169 * @return GoogleTranslate
171170 */
172- public function setTokenProvider (TokenProviderInterface $ tokenProvider ) : self
171+ public function setTokenProvider (TokenProviderInterface $ tokenProvider ): self
173172 {
174173 $ this ->tokenProvider = $ tokenProvider ;
175174 return $ this ;
@@ -218,7 +217,7 @@ public static function trans(string $string, string $target = 'en', string $sour
218217 * @throws ErrorException If the HTTP request fails
219218 * @throws UnexpectedValueException If received data cannot be decoded
220219 */
221- public function translate (string $ string ) : string
220+ public function translate (string $ string ): string
222221 {
223222 /*
224223 * if source lang and target lang are the same
@@ -293,7 +292,7 @@ public function translate(string $string) : string
293292 * @throws UnexpectedValueException If received data cannot be decoded
294293 * @return array|string Response
295294 */
296- public function getResponse (string $ string ) : array
295+ public function getResponse (string $ string ): array
297296 {
298297 $ queryArray = array_merge ($ this ->urlParams , [
299298 'sl ' => $ this ->source ,
@@ -331,7 +330,7 @@ public function getResponse(string $string) : array
331330 * @param string $lang Langauge code to verify
332331 * @return bool
333332 */
334- protected function isValidLocale (string $ lang ) : bool
333+ protected function isValidLocale (string $ lang ): bool
335334 {
336335 return (bool ) preg_match ('/^([a-z]{2})(-[A-Z]{2})?$/ ' , $ lang );
337336 }
0 commit comments