@@ -120,7 +120,7 @@ public function eject(): void
120120
121121 $ type = $ this ->translatedProperty ->getType ();
122122 if ($ type instanceof ReflectionNamedType && TranslatableInterface::class === $ type ->getName () && \is_string ($ value )) {
123- if (! $ this ->valueForEjection || $ this ->valueForEjection ->getPrimaryValue () !== $ value ) {
123+ if ($ this ->valueForEjection === null || $ this ->valueForEjection ->getPrimaryValue () !== $ value ) {
124124 $ this ->valueForEjection = new UninitializedPersistentTranslatable ($ value );
125125 }
126126 $ value = $ this ->valueForEjection ;
@@ -167,12 +167,13 @@ private function createTranslationEntity(string $locale): object
167167
168168 public function setTranslation (mixed $ value , ?string $ locale = null ): void
169169 {
170- $ locale = $ locale ?: $ this ->getDefaultLocale ();
170+ $ locale ??= $ this ->getDefaultLocale ();
171+
171172 if ($ locale === $ this ->primaryLocale ) {
172173 $ this ->setPrimaryValue ($ value );
173174 } else {
174175 $ entity = $ this ->getTranslationEntity ($ locale );
175- if (! $ entity ) {
176+ if ($ entity === null ) {
176177 $ entity = $ this ->createTranslationEntity ($ locale );
177178 }
178179 $ this ->translationProperty ->setValue ($ entity , $ value );
@@ -184,13 +185,15 @@ public function setTranslation(mixed $value, ?string $locale = null): void
184185 */
185186 public function translate (?string $ locale = null ): mixed
186187 {
187- $ locale = $ locale ?: $ this ->getDefaultLocale ();
188+ $ locale ??= $ this ->getDefaultLocale ();
189+
188190 try {
189191 if ($ locale === $ this ->primaryLocale ) {
190192 return $ this ->primaryValue ;
191193 }
192194
193- if ($ entity = $ this ->getTranslationEntity ($ locale )) {
195+ $ entity = $ this ->getTranslationEntity ($ locale );
196+ if ($ entity !== null ) {
194197 $ translated = $ this ->translationProperty ->getValue ($ entity );
195198 if (null !== $ translated ) {
196199 return $ translated ;
@@ -212,12 +215,12 @@ public function translate(?string $locale = null): mixed
212215 public function isTranslatedInto (string $ locale ): bool
213216 {
214217 if ($ locale === $ this ->primaryLocale ) {
215- return ! empty ( $ this ->primaryValue ) ;
218+ return $ this -> primaryValue !== '' && $ this ->primaryValue !== null ;
216219 }
217220
218221 $ entity = $ this ->getTranslationEntity ($ locale );
219222
220- return $ entity && null !== $ this ->translationProperty ->getValue ($ entity );
223+ return $ entity !== null && $ this ->translationProperty ->getValue ($ entity ) !== null ;
221224 }
222225
223226 public function __toString (): string
@@ -279,7 +282,7 @@ private function stringifyException(Throwable $e): string
279282 {
280283 $ exceptionAsString = '' ;
281284 while (null !== $ e ) {
282- if (! empty ( $ exceptionAsString) ) {
285+ if ($ exceptionAsString !== '' ) {
283286 $ exceptionAsString .= \PHP_EOL .'Previous exception: ' .\PHP_EOL ;
284287 }
285288 $ exceptionAsString .= \sprintf (
0 commit comments