33namespace OpenSoutheners \LaravelDataMapper \Mappers ;
44
55use Illuminate \Contracts \Container \ContextualAttribute ;
6- use Illuminate \Database \Eloquent \Model ;
76use Illuminate \Support \Collection ;
87use Illuminate \Support \Str ;
98use OpenSoutheners \LaravelDataMapper \Attributes \NormaliseProperties ;
@@ -44,7 +43,7 @@ public function assert(MappingValue $mappingValue): bool
4443 public function resolve (MappingValue $ mappingValue ): void
4544 {
4645 $ class = new ReflectionClass ($ mappingValue ->preferredTypeClass );
47-
46+
4847 $ data = [];
4948
5049 $ mappingData = is_string ($ mappingValue ->data ) ? json_decode ($ mappingValue ->data , true ) : $ mappingValue ->data ;
@@ -59,7 +58,7 @@ public function resolve(MappingValue $mappingValue): void
5958 $ value = $ propertiesData [$ key ] ?? null ;
6059
6160 $ type = app (PropertyInfoExtractor::class)->typeInfo ($ class ->getName (), $ key );
62-
61+
6362 /** @var \Illuminate\Support\Collection<\ReflectionAttribute> $propertyAttributes */
6463 $ propertyAttributes = Collection::make ($ property ->getAttributes ());
6564
@@ -76,21 +75,21 @@ public function resolve(MappingValue $mappingValue): void
7675 if (is_null ($ value )) {
7776 continue ;
7877 }
79-
78+
8079 $ unwrappedType = app (PropertyInfoExtractor::class)->unwrapType ($ type );
81-
80+
8281 if ($ type instanceof Type \NullableType) {
8382 $ type = $ type ->getWrappedType ();
8483 }
85-
84+
8685 if ($ type instanceof Type \CollectionType) {
8786 $ data [$ key ] = map ($ value )
8887 ->through ((string ) $ unwrappedType )
8988 ->to ($ type ->getCollectionValueType ());
90-
89+
9190 continue ;
9291 }
93-
92+
9493 $ data [$ key ] = match (true ) {
9594 $ type instanceof Type \ObjectType => map ($ value )->to ((string ) $ type ),
9695 default => $ value ,
@@ -106,7 +105,7 @@ public function resolve(MappingValue $mappingValue): void
106105 protected function normalisePropertyKey (MappingValue $ mappingValue , string $ key ): ?string
107106 {
108107 $ class = new ReflectionClass ($ mappingValue ->objectClass );
109-
108+
110109 $ normaliseProperty = count ($ class ->getAttributes (NormaliseProperties::class)) > 0
111110 ?: (app ('config ' )->get ('data-mapper.normalise_properties ' ) ?? true );
112111
0 commit comments