@@ -117,7 +117,13 @@ class GoogleTranslate
117117 * @param TokenProviderInterface|null $tokenProvider
118118 * @param bool|string $preserveParameters Boolean or custom regex pattern to match parameters
119119 */
120- public function __construct (string $ target = 'en ' , string $ source = null , array $ options = [], TokenProviderInterface $ tokenProvider = null , bool |string $ preserveParameters = false )
120+ public function __construct (
121+ string $ target = 'en ' ,
122+ ?string $ source = null ,
123+ array $ options = [],
124+ ?TokenProviderInterface $ tokenProvider = null ,
125+ bool |string $ preserveParameters = false
126+ )
121127 {
122128 $ this ->client = new Client ();
123129 $ this ->setTokenProvider ($ tokenProvider ?? new GoogleTokenGenerator )
@@ -145,7 +151,7 @@ public function setTarget(string $target): self
145151 * @param string|null $source Source language code (null for automatic language detection)
146152 * @return GoogleTranslate
147153 */
148- public function setSource (string $ source = null ): self
154+ public function setSource (? string $ source = null ): self
149155 {
150156 $ this ->source = $ source ?? 'auto ' ;
151157 return $ this ;
@@ -224,7 +230,14 @@ public function getLastDetectedSource(): ?string
224230 * @throws TranslationRequestException If any other HTTP related error occurs
225231 * @throws TranslationDecodingException If response JSON cannot be decoded
226232 */
227- public static function trans (string $ string , string $ target = 'en ' , string $ source = null , array $ options = [], TokenProviderInterface $ tokenProvider = null , bool |string $ preserveParameters = false ): ?string
233+ public static function trans (
234+ string $ string ,
235+ string $ target = 'en ' ,
236+ ?string $ source = null ,
237+ array $ options = [],
238+ ?TokenProviderInterface $ tokenProvider = null ,
239+ bool |string $ preserveParameters = false
240+ ): ?string
228241 {
229242 return (new self )
230243 ->setTokenProvider ($ tokenProvider ?? new GoogleTokenGenerator )
0 commit comments