Skip to content

Commit f72da59

Browse files
committed
GQL: Simplify monolingual text and coordinate value resolvers
Change-Id: I56f256280c917e8796294fbd82a3bacb0964f083
1 parent 6e4e036 commit f72da59

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

repo/WikibaseRepo.datatypes.php

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,8 @@
222222
'globe' => Type::nonNull( Type::string() ),
223223
],
224224
'resolveField' => function ( Statement|PropertyValuePair $valueProvider, $args, $context, ResolveInfo $info ) {
225-
/** @var GlobeCoordinateValue $globeCoordinateValue */
226-
$globeCoordinateValue = $valueProvider->value->content;
227-
'@phan-var GlobeCoordinateValue $globeCoordinateValue';
228-
229-
return match ( $info->fieldName ) {
230-
'latitude' => $globeCoordinateValue->getLatitude(),
231-
'longitude' => $globeCoordinateValue->getLongitude(),
232-
'precision' => $globeCoordinateValue->getPrecision(),
233-
'globe' => $globeCoordinateValue->getGlobe(),
234-
default => null,
235-
};
225+
return $valueProvider->value->content
226+
->getArrayValue()[$info->fieldName] ?? null;
236227
},
237228
] );
238229
},
@@ -271,15 +262,8 @@
271262
'text' => Type::nonNull( Type::string() ),
272263
],
273264
'resolveField' => function ( Statement|PropertyValuePair $valueProvider, $args, $context, ResolveInfo $info ) {
274-
/** @var MonolingualTextValue $value */
275-
$value = $valueProvider->value->content;
276-
'@phan-var MonolingualTextValue $value';
277-
278-
return match ( $info->fieldName ) {
279-
'language' => $value->getLanguageCode(),
280-
'text' => $value->getText(),
281-
default => null,
282-
};
265+
return $valueProvider->value->content
266+
->getArrayValue()[$info->fieldName] ?? null;
283267
},
284268
] );
285269
},

0 commit comments

Comments
 (0)